Skip to content

Extract refactors break single-line if statements into two lines #53482

Description

@andrewbranch

Bug Report

🔎 Search Terms

extract function single-line if

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about whether Tang was really invented by NASA

💻 Code

functionf(){return[].filter(x=>{if(!x)returnfalse;});}

🙁 Actual behavior

Select the arrow function callback of filter and run “Extract to inner function.” The formatting of the function contents should be the same in the extracted function.

🙂 Expected behavior

functionnewFunction(): (value: any,index: number,array: any[])=>unknown{returnx=>{if(!x)returnfalse;// New line added};}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Refactoringse.g. extract to constant or function, rename symbolEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Help WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions