-
-
Notifications
You must be signed in to change notification settings - Fork 476
Open
Description
Steps
Let's take a look at the code below:
/** @type {any} */ let foo;
console.log(42);
/** @type {string[]} */ (foo).forEach((bar) => console.log(bar));
Everything goes well when the config semi
is true
.
But after I set semi
to false
and save the code, the code will be formatted to the style as below:
/** @type {any} */ let foo
console.log(42)
/** @type {string[]} */ ;(foo).forEach((bar) => console.log(bar))
Prettier added a semicolon before the variable foo
, which made foo
lose the type string[]
and bar
lose the type string
.
And if I save the code again, the code will be reformatted again as shown below:
/** @type {any} */ let foo
console.log(42)
/** @type {string[]} */
foo.forEach((bar) => console.log(bar))
Expected result
The code should be formatted to the style as below when on saving:
/** @type {any} */ let foo
console.log(42)
;/** @type {string[]} */ (foo).forEach((bar) => console.log(bar))
The semicolon should be added before the comments, so foo
and bar
can own the type I give.
VS Code Version: 1.100.3
Prettier Extension Version: 11.0.0
OS and version: Windows 11 24H2 26100.4202
Metadata
Metadata
Assignees
Labels
No labels