Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript): do not add invalid semi for construct in interface with prettier-ignore #5469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -1338,7 +1338,8 @@ function printPathNoParens(path, options, print, args) {
separatorParts = [separator, line];
if (
(prop.node.type === "TSPropertySignature" ||
prop.node.type === "TSMethodSignature") &&
prop.node.type === "TSMethodSignature" ||
prop.node.type === "TSConstructSignature") &&
hasNodeIgnoreComment(prop.node)
) {
separatorParts.shift();
Expand Down
24 changes: 24 additions & 0 deletions tests/typescript_interface/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -67,6 +67,12 @@ interface foo extends bar {
g(): void;
h(): void;
}

interface T<T> {
// prettier-ignore
new<T>(): T<T>;
new<T>(): T<T>;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
interface Interface {
// prettier-ignore
Expand All @@ -91,6 +97,12 @@ interface foo extends bar {
h(): void;
}

interface T<T> {
// prettier-ignore
new<T>(): T<T>;
new <T>(): T<T>;
}

`;

exports[`ignore.js - typescript-verify 2`] = `
Expand All @@ -116,6 +128,12 @@ interface foo extends bar {
g(): void;
h(): void;
}

interface T<T> {
// prettier-ignore
new<T>(): T<T>;
new<T>(): T<T>;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
interface Interface {
// prettier-ignore
Expand All @@ -140,6 +158,12 @@ interface foo extends bar {
h(): void
}

interface T<T> {
// prettier-ignore
new<T>(): T<T>;
new <T>(): T<T>
}

`;

exports[`long-extends.ts - typescript-verify 1`] = `
Expand Down
6 changes: 6 additions & 0 deletions tests/typescript_interface/ignore.js
Expand Up @@ -20,3 +20,9 @@ interface foo extends bar {
g(): void;
h(): void;
}

interface T<T> {
// prettier-ignore
new<T>(): T<T>;
new<T>(): T<T>;
}