-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Proposal: simplify auto import descriptions #47631
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
Proposal: simplify auto import descriptions #47631
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.
The new wording makes sense to me. Thanks for taking a look!
@@ -6354,18 +6354,14 @@ | |||
"category": "Message", | |||
"code": 90012 | |||
}, | |||
"Import '{0}' from module \"{1}\"": { | |||
"Import '{0}' from \"{1}\"": { |
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.
This is used for both add and update? Also, nitpicky, but why one set of single quotes and one set of double quotes?
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.
I don't think I even see this message used the diff. Am I missing it?
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.
I missed it too - it's referred to by its property name in the tests.
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.
@amcasey yes, both add and update. We always use double quotes for module specifiers for some reason, and single quotes for other code quoting 🤷♂️
importKind === ImportKind.Default ? Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : Diagnostics.Add_0_to_existing_import_declaration_from_1, | ||
symbolName, | ||
moduleSpecifierWithoutQuotes | ||
]; // you too! |
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.
you too!
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.
I left it in for so long, never knowing what it was referencing.
Compliments #47552 and makes progress on #47521.
Now, when a codefix will result in a new import declaration, the message is
Add import from "foo"
. When adding an import to an existing import declaration, the message isUpdate import from "foo".
The exception is when the thing being imported doesn’t share a name with the identifier that triggered the error—the only way this happens today is when you are prompted to importReact
(or whatever your JSX element factory is) on an arbitrary JSX element name. In that case, the message isImport 'React' from "react"
.This change is based on two assumptions: