Skip to content

prettier errors on comment in export declaration #19564

Description

@kirkwaiblinger

Prettier v3.9.4
Playground link

--parser typescript

Input:

export { type /*foo */ T };

Output:

Error: Comment "foo" was not printed. Please report this error!
    at mn (https://prettier.io/lib/stable/prettier/standalone.mjs:12:5693)
    at Ve (https://prettier.io/lib/stable/prettier/standalone.mjs:22:1451)
    at async pu (https://prettier.io/lib/stable/prettier/standalone.mjs:22:6146)
    at async Dr (https://prettier.io/lib/stable/prettier/standalone.mjs:27:681)
    at async Module.<anonymous> (https://prettier.io/lib/stable/prettier/standalone.mjs:29:789)
    at async formatCode (https://prettier.io/worker.mjs?version=stable:295:12)
    at async handleFormatMessage (https://prettier.io/worker.mjs?version=stable:184:24)
    at async self.onmessage (https://prettier.io/worker.mjs?version=stable:106:14)

Second Output:

SyntaxError: Unexpected keyword or identifier. (1:8)
> 1 | Error: Comment "foo" was not printed. Please report this error!
    |        ^
  2 |     at mn (https://prettier.io/lib/stable/prettier/standalone.mjs:12:5693)
  3 |     at Ve (https://prettier.io/lib/stable/prettier/standalone.mjs:22:1451)
  4 |     at async pu (https://prettier.io/lib/stable/prettier/standalone.mjs:22:6146)

Expected output:

export { type /*foo */ T };

Why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions