#20169·prettier

Comment in a parameter property's default moves between the modifier and the name, which doesn't parse

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

Prettier 3.9.9 Playground link

bash
--parser typescript

Input:

typescript
class A {
  constructor(
    private a = (
      // c
      1
    ),
  ) {}
}

Output:

typescript
class A {
  constructor(
    private // c
    a = 1,
  ) {}
}

Second format (of the output above) fails:

',' expected. (4:5)

Expected output:

typescript
class A {
  constructor(
    // c
    private a = 1,
  ) {}
}

Why?

A line comment between private and a doesn't parse. For a regular parameter (function f(a = (// c + 1)) {}), Prettier prints the comment before the parameter; the parameter property should do the same.

Related: #16065 (a decorator comment in the same position, fixed).

Also reproduces on main (88d8e96).