Skip to content

Own-line block comment after a type annotation's : or after ... is unstable #20174

Description

@leonidaz

Prettier 3.9.9

Example 1

Playground link

--parser typescript

Input:

let a:
  /* c */
  T;

Output:

let a: /* c */
T;

Second Output:

let a: /* c */ T;

Example 2

Playground link

--parser typescript

Input:

f(...
  /* c */
  a);

Output:

f(
  .../* c */
  a,
);

Second Output:

f(.../* c */ a);

Expected output

let a: /* c */ T;

f(.../* c */ a);

Why?

The first format prints T on the next line without indentation, and breaks the call after .../* c */. The second format joins the lines.

Related: #11777 (a multi-line comment after a type).

Also reproduces on main (88d8e96).

Activity

added
lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)
area:idempotencyIssues with re-printing Prettier’s output
on Sep 29, 2026
added theissue type on Sep 29, 2026

Nithesh8678 commented on Sep 30, 2026

@Nithesh8678

Is this still available to work on? I’d like to investigate both examples and add regression tests for stable repeated formatting, with coverage for nearby comment cases. I will wait for maintainer confirmation before starting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:idempotencyIssues with re-printing Prettier’s outputlang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions