-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 1.19.1
Playground link
When using type assertions, TypeScript sometimes requires an intermediate cast to unknown due to a lack of significant overlap between types.
Prettier’s formatting currently breaks this intermediate JSDoc‑based type assertion.
Input:
const BarImpl = /** @type {BarConstructor} */ (
/** @type {unknown} */
(function Bar() {
throw new Error("Internal error: Illegal constructor");
})
);Note: BarImpl is wrapped by a Proxy later in the code, which takes care of the actual apply and construct calls, but that’s irrelevant to this issue.
Output:
const BarImpl /** @type {BarConstructor} */ =
/** @type {unknown} */
(function Bar() {
throw new Error("Internal error: Illegal constructor");
});Expected behavior:
const BarImpl = /** @type {BarConstructor} */ (
/** @type {unknown} */
(function Bar() {
throw new Error("Internal error: Illegal constructor");
})
);Metadata
Metadata
Assignees
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.