Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

OliverJAsh
Copy link
Contributor

@OliverJAsh OliverJAsh commented Dec 17, 2024

Fixes #57866

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 17, 2024
const errorNode =
inConditionalExpression ? effectiveExpr :
inReturnStatement ? node :
isArrowFunction(node.parent) && node.parent.type !== undefined ? node.parent.type :
Copy link
Contributor Author

@OliverJAsh OliverJAsh Dec 18, 2024

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error position/range for arrow functions with expression body
4 participants