Comment on a JSX superclass is duplicated on every format
Author: leonidazCreated Sep 28, 2026Updated Sep 28, 2026
Prettier 3.9.9
Example 1
--parser typescriptInput:
class A extends (/* c */ <div />) {}Output:
class A extends /* c */ (/* c */ <div />) {}Second Output:
class A extends /* c */ /* c */ (/* c */ /* c */ <div />) {}Example 2
--parser typescriptInput:
class A extends (<div /> /* c */) {}Output:
class A extends (<div /> /* c */) /* c */ {}Second Output:
class A extends (<div /> /* c */) /* c */ /* c */ {}Expected output
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).
Source: prettier/prettier