improve Diagnostics for accidentally calling type-assertion expressions#27020
Merged
DanielRosenwasser merged 2 commits intoSep 11, 2018
Conversation
Contributor
Author
|
maybe that could be a related Diagnostics? |
DanielRosenwasser
requested changes
Sep 11, 2018
Member
DanielRosenwasser
left a comment
There was a problem hiding this comment.
Looks good, and great test cases! Can we make this a related span though?
| else { | ||
| if (node.arguments.length === 1 && isTypeAssertion(first(node.arguments))) { | ||
| const text = getSourceFileOfNode(node).text; | ||
| const pos = skipTrivia(text, node.expression.end, /* stepAfterLineBreak */ true) - 1; |
Member
There was a problem hiding this comment.
Technically this function and isLineBreak seem to have differing definitions of what a line break is...
...so I don't know if that's a problem 😅
Contributor
Author
There was a problem hiding this comment.
in CRLF or LF, the skipTrivia() - 1 will always correctly,
but if only CR, that seems a problem...
| const text = getSourceFileOfNode(node).text; | ||
| const pos = skipTrivia(text, node.expression.end, /* stepAfterLineBreak */ true) - 1; | ||
| if (isLineBreak(text.charCodeAt(pos))) { | ||
| error(node.expression, Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); |
Member
There was a problem hiding this comment.
I agree! This should definitely be a related span if possible.
weswigham
approved these changes
Sep 11, 2018
DanielRosenwasser
approved these changes
Sep 11, 2018
Member
|
Thanks @Kingwl! |
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.
Fixes #26991