Skip to content

Improvements to generateTypes#28458

Merged
2 commits merged into
masterfrom
generateTypesImprovements
Nov 12, 2018
Merged

Improvements to generateTypes#28458
2 commits merged into
masterfrom
generateTypesImprovements

Conversation

@ghost

@ghost ghost commented Nov 10, 2018

Copy link
Copy Markdown
  • When an object doesn't have the prototype Object.prototype, don't treat it as a namespace but as a const. (Note we can still have a class merged with a namespace even though the class won't have Object.prototype.)
  • Deduplicate instance members detected from parsing the constructor.

@amcasey amcasey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible to me but someone who understands prototypes should probably take a look.

Comment thread src/services/codefixes/generateTypes.ts Outdated
const name = node.left.name.text;
if (!isJsPrivate(name)) members.push(createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined));
if (!isJsPrivate(name)) {
members.set(name, createProperty(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*questionOrExclamationToken*/ undefined, anyType(), /*initializer*/ undefined));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe skip the work if name is already present in members?

@ghost ghost merged commit fe1ba9b into master Nov 12, 2018
@ghost ghost deleted the generateTypesImprovements branch November 12, 2018 19:50
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
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.

2 participants