Parentheses dropped around an instantiation expression before `!` and in `export default`
Author: leonidazCreated Sep 28, 2026Updated Sep 28, 2026
Prettier 3.9.9
Example 1
--parser typescriptInput:
const a = (make<T>)!;Output:
const a = make<T>!;Second format (of the output above) fails:
Expression expected. (1:19)Example 2
--parser typescriptInput:
export default (class {})<string>;Output:
export default class {}<string>;Second format (of the output above) fails:
Expression expected. (1:32)Expected output
const a = (make<T>)!;
export default (class {})<string>;Why?
Without the parentheses the output doesn't parse. #20027 (on main) added parentheses for the callee, new, tag and superclass positions, but these two still lose them on main.
Also reproduces on main (88d8e96).
Source: prettier/prettier