js-assistant icon indicating copy to clipboard operation
js-assistant copied to clipboard

Remove braces from arrow function produces broken code when line includes cast

Open mprisehk opened this issue 1 year ago • 0 comments

Minimal example:

type User = { id: number; name: string }

const userNames = ['Alice', 'Bob']

const users = userNames
  .filter(x => !!x)
  .map((userName, i) => {
    return { id: i, name: userName } as unknown as User
  })

Choose the 'Remove braces from arrow function' refactoring for the content of the 'map' function: image

Output: image

Expected output: image

mprisehk avatar Aug 01 '24 16:08 mprisehk