Skip to content

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

@mjbvz

Description

@mjbvz

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions