Skip to content

Commit

Permalink
fix(typescript): do not add invalid semi for construct in interface w…
Browse files Browse the repository at this point in the history
…ith prettier-ignore (#5469)
  • Loading branch information
ikatyang committed Nov 14, 2018
1 parent c4b54e1 commit 5c479cc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
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>;
}

0 comments on commit 5c479cc

Please sign in to comment.