Skip to content

Fix crash when trying to import a non-exported type #36619

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 2 commits into from
Feb 5, 2020

Conversation

andrewbranch
Copy link
Member

Fixes #36592
Fixes #36614

@@ -2530,7 +2530,7 @@ namespace ts {
: error(name, Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);

addRelatedInfo(diagnostic,
createDiagnosticForNode(localSymbol.valueDeclaration, Diagnostics._0_is_declared_here, declarationName)
createDiagnosticForNode(localSymbol.valueDeclaration ?? localSymbol.declarations[0], Diagnostics._0_is_declared_here, declarationName)
Copy link
Member Author

Choose a reason for hiding this comment

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

There could be more than one declaration, but exporting any of them will fix the error, so 🤷‍♂

Copy link
Member

Choose a reason for hiding this comment

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

You could also report an error on all of them which might feel cleaner and work well too.

Copy link
Member

Choose a reason for hiding this comment

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

I'd probably just avoid the ...map and use forEach but whatever you'd prefer.

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.

Consider adding related info on each declaration instead, but looks good.

@andrewbranch
Copy link
Member Author

👍 updated

@andrewbranch
Copy link
Member Author

@typescript-bot cherry-pick this to release-3.8

@DanielRosenwasser
Copy link
Member

I've heard the bot is having trouble because of octokit.

@DanielRosenwasser
Copy link
Member

This should probably go in the RC since 2 people just reported errors on it in the VS Code codebase.

@andrewbranch andrewbranch merged commit 2047118 into microsoft:master Feb 5, 2020
@andrewbranch andrewbranch deleted the bug/36592 branch February 5, 2020 16:28
andrewbranch added a commit to andrewbranch/TypeScript that referenced this pull request Feb 5, 2020
* Fix crash when trying to import a non-exported type

* Add related info on each declaration
andrewbranch added a commit that referenced this pull request Feb 5, 2020
* Fix crash when trying to import a non-exported type

* Add related info on each declaration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants