Prettier v3.9.5
Playground link
Input:
interface Container {
'new'(id: string): number;
}
Output:
interface Container {
new(id: string): number;
}
Expected output:
interface Container {
'new'(id: string): number;
}
Why?
Unquoted new(...) in an interface/type is a construct signature, not a property named new, so as-needed should treat the quotes as required.
// Input (quoted) — compiles cleanly
interface Container { 'new'(id: string): number }
type K = keyof Container; // "new"
type M = Container['new']; // (id: string) => number
// Prettier's output (unquoted) — now errors
interface Container { new (id: string): number }
type K = keyof Container; // never
type M = Container['new']; // TS2339: Property 'new' does not exist on type 'Container'
#17694 is a similar issue.
Prettier v3.9.5
Playground link
Input:
Output:
Expected output:
Why?
Unquoted
new(...)in an interface/type is a construct signature, not a property namednew, soas-neededshould treat the quotes as required.#17694 is a similar issue.