TypeScript: Preserve a last separator for ignored object and interface types (#9318)
* Preserve ignored TypeScript signature * Add Changelog
This commit is contained in:
1 parent
16dc1a85f6
commit
e1eecfd7eb
4 files changed
+418
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
#### Preserve a last separator for ignored object and interface types (#9318 by @sosukesuzuki)
|
||||
|
||||
```ts
|
||||
// Input
|
||||
let x: {
|
||||
// prettier-ignore
|
||||
y: z;
|
||||
};
|
||||
|
||||
// Prettier stable
|
||||
let x: {
|
||||
// prettier-ignore
|
||||
y: z;;
|
||||
};
|
||||
|
||||
// Prettier master
|
||||
let x: {
|
||||
// prettier-ignore
|
||||
y: z;
|
||||
};
|
||||
```
|
||||
@@ -1184,7 +1184,13 @@ function printPathNoParens(path, options, print, args) {
|
||||
|
||||
const canHaveTrailingSeparator = !(
|
||||
n.inexact ||
|
||||
(lastElem && lastElem.type === "RestElement")
|
||||
(lastElem && lastElem.type === "RestElement") ||
|
||||
(lastElem &&
|
||||
(lastElem.type === "TSPropertySignature" ||
|
||||
lastElem.type === "TSCallSignatureDeclaration" ||
|
||||
lastElem.type === "TSMethodSignature" ||
|
||||
lastElem.type === "TSConstructSignatureDeclaration") &&
|
||||
hasNodeIgnoreComment(lastElem))
|
||||
);
|
||||
|
||||
let content;
|
||||
|
||||
@@ -314,6 +314,84 @@ interface T<T> {
|
||||
new<T>(): T<T>;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ();
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new (),
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ()
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
interface Interface {
|
||||
// prettier-ignore
|
||||
@@ -344,6 +422,84 @@ interface T<T> {
|
||||
new <T>(): T<T>
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ();
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new (),
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ()
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
@@ -382,6 +538,84 @@ interface T<T> {
|
||||
new<T>(): T<T>;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ();
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new (),
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ()
|
||||
}
|
||||
|
||||
=====================================output=====================================
|
||||
interface Interface {
|
||||
// prettier-ignore
|
||||
@@ -412,6 +646,84 @@ interface T<T> {
|
||||
new <T>(): T<T>;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
y: x;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
y: x;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
y: x;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ();
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new (),
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ()
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
|
||||
@@ -26,3 +26,81 @@ interface T<T> {
|
||||
new<T>(): T<T>;
|
||||
new<T>(): T<T>;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y;
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y,
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
x: y
|
||||
y: x
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void;
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void,
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
foo(): void
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ();
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new (),
|
||||
}
|
||||
|
||||
interface I {
|
||||
// prettier-ignore
|
||||
new ()
|
||||
}
|
||||
Reference in new issue
Block a user