Skip to content

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
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