#20176·prettier

Line comment between a superclass and its type arguments is unstable

Author: leonidazCreated Sep 28, 2026Updated Sep 28, 2026

Prettier 3.9.9

Example 1

Playground link

bash
--parser typescript

Input:

typescript
class A extends B
// c
<T> {}

Output:

typescript
class A extends B// c
<T> {}

Second Output:

typescript
class A
  extends B<T> {} // c

Example 2

Playground link

bash
--parser typescript

Input:

typescript
class A extends B // c
<T> {}

Output:

typescript
class A
  extends B<T> {} // c

Second Output:

typescript
class A extends B<T> {} // c

Expected output

typescript
class A extends B<T> {} // c

class A extends B<T> {} // c

Why?

The first format prints B// c (the comment glued to B) or breaks the heading, and the second format prints a different layout. Still reproduces on main after #19897.

Also reproduces on main (88d8e96).