Improve error position/range for arrow functions with expression body#60799
Open
OliverJAsh wants to merge 2 commits intomicrosoft:mainfrom
Open
Improve error position/range for arrow functions with expression body#60799OliverJAsh wants to merge 2 commits intomicrosoft:mainfrom
OliverJAsh wants to merge 2 commits intomicrosoft:mainfrom
Conversation
OliverJAsh
commented
Dec 17, 2024
6 tasks
OliverJAsh
commented
Dec 17, 2024
fb8722b to
796450a
Compare
796450a to
f37a0b9
Compare
OliverJAsh
commented
Dec 18, 2024
src/compiler/checker.ts
Outdated
| const errorNode = | ||
| inConditionalExpression ? effectiveExpr : | ||
| inReturnStatement ? node : | ||
| isArrowFunction(node.parent) && node.parent.type !== undefined ? node.parent.type : |
Contributor
Author
There was a problem hiding this comment.
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>
f37a0b9 to
60304d8
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #57866