Skip to content
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

Unstable block comment for implemented interfaces (TypeScript) (moved and non-idempotent) #16228

Open
akudev opened this issue Apr 19, 2024 · 0 comments
Labels
area:comments Issues with how Prettier prints comments lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues)

Comments

@akudev
Copy link

akudev commented Apr 19, 2024

Prettier 3.2.5
Playground link

--parser typescript

Input:

export default class MyClass extends MySuperClass implements /* foo */ ISomething, /* bar */ IOtherThing, /* baz */ IThirdThing {
}

export default class MyClass
  extends MySuperClass
  implements
    /* foo */ ISomething,
    /* bar */ IOtherThing,
    /* baz */ IThirdThing {}

Output:

export default class MyClass
  extends MySuperClass
  implements
    /* foo */ ISomething,
    /* bar */ IOtherThing,
    /* baz */ IThirdThing {}

export default class MyClass
  extends MySuperClass
  /* foo */
  implements ISomething, /* bar */ IOtherThing, /* baz */ IThirdThing {}

Expected output:

export default class MyClass
  extends MySuperClass
  implements
    /* foo */ ISomething,
    /* bar */ IOtherThing,
    /* baz */ IThirdThing {}

export default class MyClass
  extends MySuperClass
  implements
    /* foo */ ISomething,
    /* bar */ IOtherThing,
    /* baz */ IThirdThing {}

Why?

  1. the second class in the input is exactly the formatted output of the first class, so I'd expect that after another round of formatting it remains the same
  2. during this second formatting (=second class), the /* foo */ comment is moved away from ISomething, which is wrong, as it is likely to tell something about specifically this interface
@akudev akudev changed the title Unstable block comment for implemented interfaces (TypeScript) Unstable block comment for implemented interfaces (TypeScript) (moved and non-idempotent) Apr 19, 2024
@sosukesuzuki sosukesuzuki added area:comments Issues with how Prettier prints comments lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:comments Issues with how Prettier prints comments lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues)
Projects
None yet
Development

No branches or pull requests

2 participants