Skip to content

avoid add missing member in declaration file #29493

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

Merged

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented Jan 20, 2019

Fixes #29482

Copy link
Member

@RyanCavanaugh RyanCavanaugh left a comment

Choose a reason for hiding this comment

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

Use getSourceFileOfNode(node).isDeclarationFile

@@ -1698,6 +1698,10 @@ namespace ts {
return !!node && !!(node.flags & NodeFlags.JSDoc);
}

export function isInDeclarationFile(node: Node | undefined): boolean {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't a correct check. Ambient nodes can occur inside non-declaration files, e.g. in

declare namespace X {
}

blocks

Copy link
Member

Choose a reason for hiding this comment

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

Probably worth remembering that the original issue is specifically about the stdlib files (which generally shouldn't be editable), and not all .d.ts files. Adding more props to declarations within your own project are fine - but adding props to a stdlib or node_modules sourced declaration is prooooobably wrong. Well, it's wrong unless the addition is done by making an augmentation in the current file 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably only check file in node_modules?

Copy link
Member

Choose a reason for hiding this comment

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

We should really apply a concrete notion of where a .d.ts file "came from" - lib, upstream composite project, node_modules/types, or a local "hand-authored" .d.ts file, only the last of which is a valid rename target

Copy link
Member

Choose a reason for hiding this comment

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

isSourceFileFromExternalLibrary is that not good indication?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like exactly what we want 😃

@Kingwl Kingwl force-pushed the avoid-quickfix-for-declaration-file branch from 47f49a8 to 53b7e9d Compare January 25, 2019 03:58
@Kingwl Kingwl force-pushed the avoid-quickfix-for-declaration-file branch from 53b7e9d to bf42f5b Compare January 25, 2019 04:06
@sheetalkamat sheetalkamat merged commit 17cedda into microsoft:master Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants