Skip to content

Improve error position/range for arrow functions with expression body#60799

Open
OliverJAsh wants to merge 2 commits intomicrosoft:mainfrom
OliverJAsh:fix-57866
Open

Improve error position/range for arrow functions with expression body#60799
OliverJAsh wants to merge 2 commits intomicrosoft:mainfrom
OliverJAsh:fix-57866

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 <alexandre@unsplash.com>
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