Add Javascript declarations to index constraint check error reporting#15586
Merged
Add Javascript declarations to index constraint check error reporting#15586
Conversation
Now Javascript-style declarations like `this.foo = "bar"` are handled correctly.
mhegazy
reviewed
May 4, 2017
| let errorNode: Node; | ||
| if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) { | ||
| if (propDeclaration && | ||
| (getSpecialPropertyAssignmentKind(propDeclaration as BinaryExpression) === SpecialPropertyAssignmentKind.ThisProperty || |
Contributor
There was a problem hiding this comment.
consider moving this to the end of the check
Member
Author
There was a problem hiding this comment.
It actually needs to come first because JS-style assignments should not hit the computed property check. It won't be very expensive because most declarations are not in javascript files and even there, most declarations are not JS-style assignment declarations.
mhegazy
approved these changes
May 4, 2017
Contributor
|
@sandersn, Please port this to release-2.3 |
Member
Author
|
I'll look into normalising use of |
Member
Author
|
It's merged into 2.3 now. |
TysonAndre
reviewed
May 8, 2017
| if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) { | ||
| if (propDeclaration && | ||
| (getSpecialPropertyAssignmentKind(propDeclaration as BinaryExpression) === SpecialPropertyAssignmentKind.ThisProperty || | ||
| propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || |
There was a problem hiding this comment.
This may crash if propDeclaration.name is undefined.
see #15681
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.
Now Javascript-style declarations like
this.foo = "bar"are handledcorrectly and errors will be reported on the declaration correctly. Previously the code would check the computed property name case and crash because Javascript-style declarations have no
nameproperty.Fixes #15525