Repository navigation
quick fix for function only contains one jsx element and have not the return statement #25751
Copy link
Copy link
Closed
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Good First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScriptUpdate Docs on Next ReleaseIndicates that this PR affects docsIndicates that this PR affects docs
Milestone
Description
Activity
DanielRosenwasser commented
on Jul 18, 2018 MemberMore actionsGreat idea. It doesn't even have to be limited to JSX. I'm not sure how we'd plumb the logic through, but there are two fixes I'd have in mind:
- For any block body containing a single ExpressionStatement whose expression's type matches the expected type, suggest the following:
- Add a
returnstatement. - Remove block body braces.
- Replace braces with parentheses.
- For any block body containing only a labeled ExpressionStatement, check to see if the expected type contains a property with the same name as the label, and if so, suggest
- Wrap this block with parentheses.
Reacted by Wenlu Wang- addedSuggestionAn idea for TypeScriptAn idea for TypeScriptDomain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.
on Jul 18, 2018 - addedHelp WantedYou can do thisYou can do this
on Jul 18, 2018 should that a quickfix? maybe refactor is more suitable
DanielRosenwasser commented
on Jul 18, 2018 MemberMore actionsWell, I guess your example is a refactoring since there's no error (you just end up producing a
void[].The cases I have in mind should have an associated error.
Reacted by Wenlu Wangsometime we cannot infer the return type(no context, no type annotation)
will we ignore those case?need some help:
how could i know type are related in quick fix withoutisTypeRelatedTo😢- addedGood First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green light
on Oct 30, 2018 - addedUpdate Docs on Next ReleaseIndicates that this PR affects docsIndicates that this PR affects docs
on Apr 2, 2020 DanielRosenwasser commented
on Apr 2, 2020 MemberMore actionsThanks Wenlu Wang (@Kingwl)!
Metadata
Metadata
Assignees
Labels
Domain: Error MessagesThe issue relates to error messagingThe issue relates to error messagingDomain: LS: Quick FixesEditor-provided fixes, often called code actions.Editor-provided fixes, often called code actions.Good First IssueWell scoped, documented and has the green lightWell scoped, documented and has the green lightHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScriptUpdate Docs on Next ReleaseIndicates that this PR affects docsIndicates that this PR affects docs
Search Terms
quickfix, jsx, function
Suggestion
quick fix for function only contains one jsx element and have not the return statement
Use Cases
the pattern of a function with block body that only have one jsx element without return statement
that seems a error
could we provide a quickfix for that?
Examples
to
Checklist
My suggestion meets these guidelines: