-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix codefix-triggered auto import of aliased exports #60260
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need an extra importadder function? It seems like this could be done by doing the tryGetAutoImportableReference...
call/logic from within addImportFromExportedSymbol
(or an update to exportinfomap
?). The functions seem too similar to justify a new one, this function one skips a lot of the resolving in the existing function, and any other codefix that tries to import Alias
from a symbol reference still crashes after this PR.
(I also think this is an issue with export aliases in general, not just types)
* @internal | ||
* Information about an `import("...").SomeType` replaced by an auto-importable type reference. | ||
*/ | ||
export interface ImportTypeReplacement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"replacement
" is a little confusing to me--does this refer to export aliases in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it refers to the fact that an ImportType has been replaced by a TypeReference plus a top-level import.
@iisaduan what’s happening here is that the add-missing-members codefix generates code like someMethod(p: import("./one").SomeType, q: import("./two").default) {} which first gets transformed into someMethod(p: SomeType, q: BetterNameForDefault) {} and then we ask to auto-import the symbols for those types. But we were only passing the symbols in, which means we were losing important pieces of information:
|
Fixes #59583