Skip to content

chore(packages): replace Object interface with Record type #3681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Jun 13, 2022

Issue

Internal JS-3299

Description

Replaces Object interface with Record type

Used regular expression interface ([\w]*) \{\n. \[[^:]*: string\]: ([^;]*);\n\} for searching, and replaced it with value type $1 = Record<string, $2>;

Testing

Verified that usage of imports won't break when interface is replaced with types in TypeScript playground:

const exampleObj = {
  "one": 1,
  "two": 2,
  "three": 3
}

interface MapInterface {
  [key:string]: number;
}

type MapType = Record<string, number>;

const objInterface: MapInterface = exampleObj;
const objType: MapType = exampleObj;

const objInterfaceCopyToMap: MapType = objInterface;
const objTypeCopyToInteface: MapInterface = objType;

Verified that extending types will work in TypeScript Playground:

type MapType = Record<string, number>;

interface OldOneWhichExtendedInterface extends MapType {
  foo: number;
}

const exampleObj: OldOneWhichExtendedInterface = {
  foo: 1,
  bar: 2
}

Additional context

The base branch for this PR will be changed to main after #3680 is merged. Done


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr force-pushed the convert-obj-interface-to-type branch from b32f6d3 to 82a7105 Compare June 13, 2022 17:29
@trivikr trivikr changed the base branch from use-record-packages to main June 13, 2022 17:29
@trivikr trivikr marked this pull request as ready for review June 13, 2022 18:34
@trivikr trivikr requested a review from a team as a code owner June 13, 2022 18:34
@trivikr trivikr marked this pull request as draft June 13, 2022 18:38
@trivikr
Copy link
Member Author

trivikr commented Jun 13, 2022

Created new PR at #3683
The GitHub CI was not run on this PR, as well as it was mistakenly pushed to remote branch on upstream

@trivikr trivikr closed this Jun 13, 2022
@trivikr trivikr deleted the convert-obj-interface-to-type branch June 13, 2022 18:42
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant