#20163·prettier

Range formatting a `for…of` declaration adds a `;` that breaks the loop

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

Prettier 3.9.9 Playground link

bash
--parser typescript
--range-start 5
--range-end 12

Input:

typescript
for (const f of filters) {}

Output:

typescript
for (const f; of filters) {}

Expected output:

typescript
for (const f of filters) {}

Why?

The range covers only const f in the loop head. The declaration is formatted as a statement of its own and gets a ;, so the output doesn't parse.

Related: #16292 (range format redesign), #16721.

Also reproduces on main (88d8e96).