Skip to content

Fix completions of exports elsewhere in same file #43755

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
merged 5 commits into from
Apr 26, 2021

Conversation

andrewbranch
Copy link
Member

Fixes #43289, along with another bug I found on the way:

module.exports = { a/**/ } // has a completion for itself

and

const c = 0;
export { c as something };
export * as somethingElse from "./other";

s/**/ // has completions for 'something' and 'somethingElse'

@andrewbranch
Copy link
Member Author

andrewbranch commented Apr 23, 2021

@sandersn I realized I couldn’t really fix the primary bug (#43289) without addressing the contextual typing thing head-on, which I think I’ve done now. getContextualTypeForThisPropertyAssignment is now only used for this (and aliased-this) property assignments. We now group AssignmentDeclarationKind.ExportsProperty, .Prototype, .PrototypeProperty, and .ModuleExports together as being the simpler cases where they can have a contextual type only via a JSDoc type annotation, whereas .Property and .ThisProperty might be new declarations, might be immediately annotated with JSDoc, or might have a contextual type from the original declaration of the object/class. Some of the simpler cases were incorrectly being fed through that more complicated logic.

@andrewbranch andrewbranch requested a review from sandersn April 23, 2021 20:28
@andrewbranch
Copy link
Member Author

@typescript-bot user test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 23, 2021

Heya @andrewbranch, I've started to run the parallelized community code test suite on this PR at 61521db. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

case AssignmentDeclarationKind.ModuleExports:
case AssignmentDeclarationKind.ThisProperty:
return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
valueDeclaration ||= binaryExpression.symbol?.valueDeclaration;
Copy link
Member

Choose a reason for hiding this comment

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

switch scope rules are boooooooooo

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.

Completions broken in module.exports object literal
4 participants