-
Notifications
You must be signed in to change notification settings - Fork 13k
Fix misleading error TS2410 from issue #10601 #11176
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
Conversation
Hi @lukaselmer, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question for investigation and one request for rewording the error message.
@@ -1279,7 +1279,7 @@ | |||
"category": "Error", | |||
"code": 2409 | |||
}, | |||
"All symbols within a 'with' block will be resolved to 'any'.": { | |||
"Unsupported 'with' statement, all symbols within a 'with' block will be resolved to 'any'.": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would word the error as "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that.
if (!hasParseDiagnostics(sourceFile)) { | ||
const start = getSpanOfTokenAtPosition(sourceFile, node.pos).start; | ||
const end = node.statement.pos; | ||
grammarErrorAtPos(sourceFile, start, end - start, Diagnostics.Unsupported_with_statement_all_symbols_within_a_with_block_will_be_resolved_to_any); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How bad is the error span if you just say error(node, ...)
? It would save a lot of fiddly code. But I suspect that it underlines the entire with
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it underlines the whole with block. Therefore I would still go with this solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
Fixes #10601
'Bug' or 'Accepting PRs' or is in the Community milestone: see Misleading error TS2410 #10601
master
branchjake runtests
locally: No, tslint did not run when I checked out the project. The tests run though.