prettier / prettier

Prettier is an opinionated code formatter.
https://prettier.io
MIT License
49.4k stars 4.36k forks source link

Ugly formatting #15205

Open so1ve opened 1 year ago

so1ve commented 1 year ago

Prettier 3.0.1 Playground link

--parser typescript
--trailing-comma es5

Input:

export type Equals<X, Y> =
  (<T>() => T extends X ? 1 : 2) extends
  (<T>() => T extends Y ? 1 : 2)
    ? true
    : false;

Output:

export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends <
  T,
>() => T extends Y ? 1 : 2
  ? true
  : false;

Expected behavior:

Should be the same as the input, or something better

shaiallseated commented 1 year ago

i agree very ugly yikes 😣😣😣😣😣😣😣

SteveCarellTheOfficeGIF

seiyab commented 11 months ago

Just for information: I think this output has multiple different problems.

so1ve commented 11 months ago

Thanks for your investigation ❤️

seiyab commented 9 months ago

Prettier 3.2.4 Playground link

--parser typescript
--trailing-comma es5

Input:

export type Equals<X, Y> =
  (<T>() => T extends X ? 1 : 2) extends
  (<T>() => T extends Y ? 1 : 2)
    ? true
    : false;

Output:

export type Equals<X, Y> =
  (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2
    ? true
    : false;