-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Improve error position/range for arrow functions with expression body #60799
base: main
Are you sure you want to change the base?
Conversation
tests/baselines/reference/arrowFunctionReturnTypeErrorSpan.errors.txt
Outdated
Show resolved
Hide resolved
fb8722b
to
796450a
Compare
796450a
to
f37a0b9
Compare
const errorNode = | ||
inConditionalExpression ? effectiveExpr : | ||
inReturnStatement ? node : | ||
isArrowFunction(node.parent) && node.parent.type !== undefined ? node.parent.type : |
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.
Alternatively we could position the error on =>
:
If the span highlights the return type, it might suggest an issue with the return type rather than the returned value/expression. =>
on the other hand would suggest it could be an issue with either the return type or the value. This would be synonymous to the behaviour with block body arrow functions where we highlight the return
keyboard.
However, the error might be harder to see, because =>
is only 2 characters. I would personally be fine with this.
Co-authored-by: Alexandre St-Louis Fortier <[email protected]>
f37a0b9
to
60304d8
Compare
Fixes #57866