Skip to content

add spelling suggestion support for module import #22283

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 1 commit into from
Mar 2, 2018

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented Mar 2, 2018

Fixes #21875

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

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

Looks good!

As a follow-up for a separate PR, I think it would be ideal to see if we could make the quick-fix here actually fix up all local references to this import within the module. I'll file that separately after this goes in.

error(name, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), declarationNameToString(name));
const suggestion = getSuggestionForNonexistentModule(name, targetSymbol);
if (suggestion !== undefined) {
error(name, Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_2, getFullyQualifiedName(moduleSymbol), declarationNameToString(name), suggestion);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe move the first two arguments out of each call to error to avoid the duplication in logic.

@Kingwl Kingwl force-pushed the export-spelling branch from c11d7c5 to fdd004d Compare March 2, 2018 07:21
@@ -16188,6 +16196,11 @@ namespace ts {
return result && symbolName(result);
}

function getSuggestionForNonexistentModule(name: Identifier, targetModule: Symbol): string | undefined {
Copy link
Member

Choose a reason for hiding this comment

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

one small nit: getSuggestionForNonexistentExport might be a better name. Not sure if it's worth changing through.

@sandersn sandersn merged commit b151573 into microsoft:master Mar 2, 2018
@Kingwl Kingwl deleted the export-spelling branch March 5, 2018 10:14
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
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.

3 participants