Skip to content

'Infer function return type' quick fix generates invalid code for arrow functions without parens #42519

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

Closed
mjbvz opened this issue Jan 27, 2021 · 0 comments · Fixed by #42532
Closed
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 27, 2021

Bug Report

🔎 Search Terms

  • Quick fix
  • code action
  • infer function return type

🕗 Version & Regression Information

TypeScript version: 4.2.0-dev.20210125

💻 Code

const a = async x => {
    return 1; 
}

Trigger the infer function return type fix here

🙁 Actual behavior

This results in:

const a = async x: Promise<number> => {
    return 1;
}

🙂 Expected behavior

Instead a set of parameter parens needs to be added in this case:

const a = async (x): Promise<number> => {
    return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
2 participants