#20173·prettier

Comment on a JSX superclass is duplicated on every format

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

Prettier 3.9.9

Example 1

Playground link

bash
--parser typescript

Input:

typescript
class A extends (/* c */ <div />) {}

Output:

typescript
class A extends /* c */ (/* c */ <div />) {}

Second Output:

typescript
class A extends /* c */ /* c */ (/* c */ /* c */ <div />) {}

Example 2

Playground link

bash
--parser typescript

Input:

typescript
class A extends (<div /> /* c */) {}

Output:

typescript
class A extends (<div /> /* c */) /* c */ {}

Second Output:

typescript
class A extends (<div /> /* c */) /* c */ /* c */ {}

Expected output

typescript
class A extends (/* c */ <div />) {}

class A extends (<div /> /* c */) {}

Why?

Each format adds another copy of the comment next to the parentheses, so the output grows every time. With a non-JSX superclass (extends (/* c */ a())) the comment prints once.

Also reproduces on main (88d8e96).