Fix crash when binding jsdoc-style inner namepaths#25106
Merged
Conversation
getNameOfDeclaration actually doesn't handle all declarations, only those that produce names that could be reasonably used as an identifier. Until now, getDeclarationIdentifier assumed that getNameOfDeclaration always returned a name. This caused crashes whenever we tried to get the name of something like a Constructor.
mhegazy
reviewed
Jun 20, 2018
| @@ -4847,7 +4847,7 @@ namespace ts { | |||
|
|
|||
| function getDeclarationIdentifier(node: Declaration | Expression): Identifier | undefined { | |||
| const name = getNameOfDeclaration(node); | |||
Contributor
There was a problem hiding this comment.
can we fix getNameOfDeclaration as well to return nullable type? i do not know where else our assumptions are wrong, and this seems like a good time as any to fix them once and for all.
Member
Author
There was a problem hiding this comment.
I'll try. It's used a lot of places without checking, but many of these follow a similar error-reporting pattern that might be supportable with a non-nullable overload or something.
This requires all callers to handle it, which turns out now to be too disruptive.
sandersn
commented
Jun 21, 2018
| } | ||
|
|
||
| function isIdentifierThatStartsWithUnderScore(node: Node) { | ||
| function isIdentifierThatStartsWithUnderscore(node: Node) { |
Member
Author
There was a problem hiding this comment.
I also eliminated the now-redundant parameterNameStartsWithUnderscore and fixed the capitalisation of isIdentifierThatStartsWithUnderscore.
mhegazy
approved these changes
Jun 21, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getNameOfDeclaration actually doesn't handle all declarations, only those that produce names that could be reasonably used as an identifier. Until now, getDeclarationIdentifier assumed that getNameOfDeclaration always returned a name. This caused crashes whenever we tried to get the name of something like a Constructor.
Fixes #25104