Fix comment placement in assignment-like type aliases (TSTypeAliasDeclaration) (#19410)
Co-authored-by: WhoamiI00 <anktiisop12@gmail.com> Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
10 files changed
+366
-62
No files matched your search
@@ -0,0 +1,22 @@
|
|||||||
|
#### Preserve comment position after `=` in type alias declarations (#19410 by @WhoamiI00)
|
||||||
|
|
||||||
|
<!-- prettier-ignore -->
|
||||||
|
```ts
|
||||||
|
// Input
|
||||||
|
type A =
|
||||||
|
/* 1 */ | /* 2 */ (
|
||||||
|
/* 3 */ | /* 4 */ {
|
||||||
|
key: string;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Prettier stable
|
||||||
|
type A /* 2 */ = /* 1 */ /* 3 */ /* 4 */ {
|
||||||
|
key: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Prettier main
|
||||||
|
type A = /* 1 */ /* 2 */ /* 3 */ /* 4 */ {
|
||||||
|
key: string;
|
||||||
|
};
|
||||||
|
```
|
||||||
@@ -139,6 +139,7 @@ function handleRemainingComment(context) {
|
|||||||
handleParenthesizedExpressionTrailingComment,
|
handleParenthesizedExpressionTrailingComment,
|
||||||
handleBinaryCastExpressionComment,
|
handleBinaryCastExpressionComment,
|
||||||
handleUnionTypeLeadingComments,
|
handleUnionTypeLeadingComments,
|
||||||
|
handleAssignmentLikeAnnotationLeadingComments,
|
||||||
].some((fn) => fn(context));
|
].some((fn) => fn(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -782,6 +783,28 @@ function handleVariableDeclaratorComments({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleAssignmentLikeAnnotationLeadingComments({
|
||||||
|
comment,
|
||||||
|
enclosingNode,
|
||||||
|
followingNode,
|
||||||
|
options,
|
||||||
|
}) {
|
||||||
|
if (isAssignmentLikeNode(enclosingNode) && followingNode) {
|
||||||
|
// @ts-expect-error -- Safe
|
||||||
|
const leftSide = enclosingNode.id ?? enclosingNode.left;
|
||||||
|
const equalsTokenIndex = stripComments(options).indexOf(
|
||||||
|
"=",
|
||||||
|
locEnd(leftSide),
|
||||||
|
);
|
||||||
|
if (locStart(comment) >= equalsTokenIndex) {
|
||||||
|
addLeadingComment(followingNode, comment);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function handleTSFunctionTrailingComments({
|
function handleTSFunctionTrailingComments({
|
||||||
comment,
|
comment,
|
||||||
enclosingNode,
|
enclosingNode,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const unstableTests = new Map(
|
|||||||
(options) => options.proseWrap === "always",
|
(options) => options.proseWrap === "always",
|
||||||
],
|
],
|
||||||
"flow/hook/declare-hook.js",
|
"flow/hook/declare-hook.js",
|
||||||
"flow/hook/comments-before-arrow.js",
|
|
||||||
"flow/hook/hook-type-annotation.js",
|
"flow/hook/hook-type-annotation.js",
|
||||||
"flow/comments/type_annotations.js",
|
"flow/comments/type_annotations.js",
|
||||||
"typescript/prettier-ignore/mapped-types.ts",
|
"typescript/prettier-ignore/mapped-types.ts",
|
||||||
|
|||||||
@@ -192,25 +192,25 @@ type A2 = C;
|
|||||||
type A3 = C;
|
type A3 = C;
|
||||||
type A4 = C;
|
type A4 = C;
|
||||||
type A5 = C;
|
type A5 = C;
|
||||||
type A6 /*1*/ = C;
|
type A6 = /*1*/ C;
|
||||||
type A7 /*1*/ = C;
|
type A7 = /*1*/ C;
|
||||||
type A8 /*1*/ = C;
|
type A8 = /*1*/ C;
|
||||||
type A9 /*1*/ = C;
|
type A9 = /*1*/ C;
|
||||||
type A10 /*1*/ = /*2*/ C;
|
type A10 = /*1*/ /*2*/ C;
|
||||||
type A11 /*1*/ = /*2*/ C;
|
type A11 = /*1*/ /*2*/ C;
|
||||||
type A12 /*1*/ = C;
|
type A12 = /*1*/ C;
|
||||||
type A13 = /*1*/ C;
|
type A13 = /*1*/ C;
|
||||||
|
|
||||||
type Aa1 = /*1*/ /*2*/ C & D;
|
type Aa1 = /*1*/ /*2*/ C & D;
|
||||||
type Aa2 = /*1*/ /*2*/ C & /*3*/ D;
|
type Aa2 = /*1*/ /*2*/ C & /*3*/ D;
|
||||||
type Aa3 = /*1*/ /*2*/ C & /*3*/ D /*4*/;
|
type Aa3 = /*1*/ /*2*/ C & /*3*/ D /*4*/;
|
||||||
|
|
||||||
type C1 /*1*/ = a & b;
|
type C1 = /*1*/ a & b;
|
||||||
type C2 /*1*/ = a & b;
|
type C2 = /*1*/ a & b;
|
||||||
type C3 /*1*/ = a & b;
|
type C3 = /*1*/ a & b;
|
||||||
type C4 /*1*/ = a & b;
|
type C4 = /*1*/ a & b;
|
||||||
type C5 /*1*/ = a & b;
|
type C5 = /*1*/ a & b;
|
||||||
type C6 /*0*/ /*1*/ = a & b;
|
type C6 /*0*/ = /*1*/ a & b;
|
||||||
|
|
||||||
type Ctor = (new () => X) & Y;
|
type Ctor = (new () => X) & Y;
|
||||||
|
|
||||||
@@ -409,25 +409,25 @@ type A2 = C
|
|||||||
type A3 = C
|
type A3 = C
|
||||||
type A4 = C
|
type A4 = C
|
||||||
type A5 = C
|
type A5 = C
|
||||||
type A6 /*1*/ = C
|
type A6 = /*1*/ C
|
||||||
type A7 /*1*/ = C
|
type A7 = /*1*/ C
|
||||||
type A8 /*1*/ = C
|
type A8 = /*1*/ C
|
||||||
type A9 /*1*/ = C
|
type A9 = /*1*/ C
|
||||||
type A10 /*1*/ = /*2*/ C
|
type A10 = /*1*/ /*2*/ C
|
||||||
type A11 /*1*/ = /*2*/ C
|
type A11 = /*1*/ /*2*/ C
|
||||||
type A12 /*1*/ = C
|
type A12 = /*1*/ C
|
||||||
type A13 = /*1*/ C
|
type A13 = /*1*/ C
|
||||||
|
|
||||||
type Aa1 = /*1*/ /*2*/ C & D
|
type Aa1 = /*1*/ /*2*/ C & D
|
||||||
type Aa2 = /*1*/ /*2*/ C & /*3*/ D
|
type Aa2 = /*1*/ /*2*/ C & /*3*/ D
|
||||||
type Aa3 = /*1*/ /*2*/ C & /*3*/ D /*4*/
|
type Aa3 = /*1*/ /*2*/ C & /*3*/ D /*4*/
|
||||||
|
|
||||||
type C1 /*1*/ = a & b
|
type C1 = /*1*/ a & b
|
||||||
type C2 /*1*/ = a & b
|
type C2 = /*1*/ a & b
|
||||||
type C3 /*1*/ = a & b
|
type C3 = /*1*/ a & b
|
||||||
type C4 /*1*/ = a & b
|
type C4 = /*1*/ a & b
|
||||||
type C5 /*1*/ = a & b
|
type C5 = /*1*/ a & b
|
||||||
type C6 /*0*/ /*1*/ = a & b
|
type C6 /*0*/ = /*1*/ a & b
|
||||||
|
|
||||||
type Ctor = (new () => X) & Y
|
type Ctor = (new () => X) & Y
|
||||||
|
|
||||||
@@ -625,25 +625,25 @@ type A2 = C;
|
|||||||
type A3 = C;
|
type A3 = C;
|
||||||
type A4 = C;
|
type A4 = C;
|
||||||
type A5 = C;
|
type A5 = C;
|
||||||
type A6 /*1*/ = C;
|
type A6 = /*1*/ C;
|
||||||
type A7 /*1*/ = C;
|
type A7 = /*1*/ C;
|
||||||
type A8 /*1*/ = C;
|
type A8 = /*1*/ C;
|
||||||
type A9 /*1*/ = C;
|
type A9 = /*1*/ C;
|
||||||
type A10 /*1*/ = /*2*/ C;
|
type A10 = /*1*/ /*2*/ C;
|
||||||
type A11 /*1*/ = /*2*/ C;
|
type A11 = /*1*/ /*2*/ C;
|
||||||
type A12 /*1*/ = C;
|
type A12 = /*1*/ C;
|
||||||
type A13 = /*1*/ C;
|
type A13 = /*1*/ C;
|
||||||
|
|
||||||
type Aa1 = /*1*/ /*2*/ C & D;
|
type Aa1 = /*1*/ /*2*/ C & D;
|
||||||
type Aa2 = /*1*/ /*2*/ C & /*3*/ D;
|
type Aa2 = /*1*/ /*2*/ C & /*3*/ D;
|
||||||
type Aa3 = /*1*/ /*2*/ C & /*3*/ D /*4*/;
|
type Aa3 = /*1*/ /*2*/ C & /*3*/ D /*4*/;
|
||||||
|
|
||||||
type C1 /*1*/ = a & b;
|
type C1 = /*1*/ a & b;
|
||||||
type C2 /*1*/ = a & b;
|
type C2 = /*1*/ a & b;
|
||||||
type C3 /*1*/ = a & b;
|
type C3 = /*1*/ a & b;
|
||||||
type C4 /*1*/ = a & b;
|
type C4 = /*1*/ a & b;
|
||||||
type C5 /*1*/ = a & b;
|
type C5 = /*1*/ a & b;
|
||||||
type C6 /*0*/ /*1*/ = a & b;
|
type C6 /*0*/ = /*1*/ a & b;
|
||||||
|
|
||||||
type Ctor = (new () => X) & Y;
|
type Ctor = (new () => X) & Y;
|
||||||
|
|
||||||
|
|||||||
+124
-13
@@ -91,24 +91,135 @@ type B2 = C;
|
|||||||
type B3 = C;
|
type B3 = C;
|
||||||
type B4 = C;
|
type B4 = C;
|
||||||
type B5 = C;
|
type B5 = C;
|
||||||
type B6 /*1*/ = C;
|
type B6 = /*1*/ C;
|
||||||
type B7 /*1*/ = C;
|
type B7 = /*1*/ C;
|
||||||
type B8 /*1*/ = C;
|
type B8 = /*1*/ C;
|
||||||
type B9 /*1*/ = C;
|
type B9 = /*1*/ C;
|
||||||
type B10 /*1*/ = /*2*/ C;
|
type B10 = /*1*/ /*2*/ C;
|
||||||
type B11 /*1*/ = /*2*/ C;
|
type B11 = /*1*/ /*2*/ C;
|
||||||
type B12 /*1*/ = C;
|
type B12 = /*1*/ C;
|
||||||
|
|
||||||
type Bb1 = /*1*/ /*2*/ C & D;
|
type Bb1 = /*1*/ /*2*/ C & D;
|
||||||
type Bb2 = /*1*/ /*2*/ C & /*3*/ D;
|
type Bb2 = /*1*/ /*2*/ C & /*3*/ D;
|
||||||
type Bb3 = /*1*/ /*2*/ C & /*3*/ D /*4*/;
|
type Bb3 = /*1*/ /*2*/ C & /*3*/ D /*4*/;
|
||||||
|
|
||||||
type D1 /*1*/ = a & b;
|
type D1 = /*1*/ a & b;
|
||||||
type D2 /*1*/ = a & b;
|
type D2 = /*1*/ a & b;
|
||||||
type D3 /*1*/ = a & b;
|
type D3 = /*1*/ a & b;
|
||||||
type D4 /*1*/ = a & b;
|
type D4 = /*1*/ a & b;
|
||||||
type D5 /*1*/ = a & b;
|
type D5 = /*1*/ a & b;
|
||||||
type D6 /*0*/ /*1*/ = a & b;
|
type D6 /*0*/ = /*1*/ a & b;
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`single-member.ts format 1`] = `
|
||||||
|
====================================options=====================================
|
||||||
|
parsers: ["typescript", "flow"]
|
||||||
|
printWidth: 80 (default) |
|
||||||
|
=====================================input======================================
|
||||||
|
// https://github.com/oxc-project/oxc/pull/21915
|
||||||
|
|
||||||
|
// export type aType = & // Comment
|
||||||
|
// "VALUE";
|
||||||
|
|
||||||
|
export type bType = &
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type cType = & /* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type dType = /* Comment */
|
||||||
|
& "VALUE";
|
||||||
|
|
||||||
|
// export type eType = // Comment
|
||||||
|
// & "VALUE";
|
||||||
|
|
||||||
|
export type fType = &
|
||||||
|
/* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type gType = &
|
||||||
|
// Comment
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type hType = &
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type iType = /* Comment */ /* Comment */ & "VALUE";
|
||||||
|
|
||||||
|
export type jType = /* Comment */
|
||||||
|
/* Comment */ & "VALUE";
|
||||||
|
|
||||||
|
export type kType = /* Comment */
|
||||||
|
&
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type lType = /* Comment */ &
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type mType = & "VALUE" /* Comment */;
|
||||||
|
|
||||||
|
export type nType = // Comment
|
||||||
|
& /* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
// type oType = // Comment
|
||||||
|
// & // Comment
|
||||||
|
// "VALUE"
|
||||||
|
|
||||||
|
=====================================output=====================================
|
||||||
|
// https://github.com/oxc-project/oxc/pull/21915
|
||||||
|
|
||||||
|
// export type aType = & // Comment
|
||||||
|
// "VALUE";
|
||||||
|
|
||||||
|
export type bType =
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type cType = /* Comment */ "VALUE";
|
||||||
|
|
||||||
|
export type dType = /* Comment */ "VALUE";
|
||||||
|
|
||||||
|
// export type eType = // Comment
|
||||||
|
// & "VALUE";
|
||||||
|
|
||||||
|
export type fType =
|
||||||
|
/* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type gType =
|
||||||
|
// Comment
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type hType = "VALUE";
|
||||||
|
|
||||||
|
export type iType = /* Comment */ /* Comment */ "VALUE";
|
||||||
|
|
||||||
|
export type jType = /* Comment */ /* Comment */ "VALUE";
|
||||||
|
|
||||||
|
export type kType =
|
||||||
|
/* Comment */
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type lType =
|
||||||
|
/* Comment */ // Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type mType = "VALUE"; /* Comment */
|
||||||
|
|
||||||
|
export type nType = /* Comment */ "VALUE"; // Comment
|
||||||
|
|
||||||
|
// type oType = // Comment
|
||||||
|
// & // Comment
|
||||||
|
// "VALUE"
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// https://github.com/oxc-project/oxc/pull/21915
|
||||||
|
|
||||||
|
// export type aType = & // Comment
|
||||||
|
// "VALUE";
|
||||||
|
|
||||||
|
export type bType = &
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type cType = & /* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type dType = /* Comment */
|
||||||
|
& "VALUE";
|
||||||
|
|
||||||
|
// export type eType = // Comment
|
||||||
|
// & "VALUE";
|
||||||
|
|
||||||
|
export type fType = &
|
||||||
|
/* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type gType = &
|
||||||
|
// Comment
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type hType = &
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type iType = /* Comment */ /* Comment */ & "VALUE";
|
||||||
|
|
||||||
|
export type jType = /* Comment */
|
||||||
|
/* Comment */ & "VALUE";
|
||||||
|
|
||||||
|
export type kType = /* Comment */
|
||||||
|
&
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type lType = /* Comment */ &
|
||||||
|
// Comment
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
export type mType = & "VALUE" /* Comment */;
|
||||||
|
|
||||||
|
export type nType = // Comment
|
||||||
|
& /* Comment */
|
||||||
|
"VALUE";
|
||||||
|
|
||||||
|
// type oType = // Comment
|
||||||
|
// & // Comment
|
||||||
|
// "VALUE"
|
||||||
@@ -567,13 +567,13 @@ type A2 = C;
|
|||||||
type A3 = C;
|
type A3 = C;
|
||||||
type A4 = C;
|
type A4 = C;
|
||||||
type A5 = C;
|
type A5 = C;
|
||||||
type A6 /*1*/ = C;
|
type A6 = /*1*/ C;
|
||||||
type A7 /*1*/ = C;
|
type A7 = /*1*/ C;
|
||||||
type A8 /*1*/ = C;
|
type A8 = /*1*/ C;
|
||||||
type A9 /*1*/ = C;
|
type A9 = /*1*/ C;
|
||||||
type A10 /*1*/ = /*2*/ C;
|
type A10 = /*1*/ /*2*/ C;
|
||||||
type A11 /*1*/ = /*2*/ C;
|
type A11 = /*1*/ /*2*/ C;
|
||||||
type A12 /*1*/ = C;
|
type A12 = /*1*/ C;
|
||||||
type A13 = /*1*/ C;
|
type A13 = /*1*/ C;
|
||||||
|
|
||||||
type Aa1 = /*1*/ /*2*/ C | D;
|
type Aa1 = /*1*/ /*2*/ C | D;
|
||||||
@@ -583,7 +583,7 @@ type Aa3 = /*1*/ /*2*/ C | /*3*/ D /*4*/;
|
|||||||
type C1 = /*1*/ a | b;
|
type C1 = /*1*/ a | b;
|
||||||
type C2 = /*1*/ a | b;
|
type C2 = /*1*/ a | b;
|
||||||
type C3 = /*1*/ a | b;
|
type C3 = /*1*/ a | b;
|
||||||
type C4 /*1*/ = a | b;
|
type C4 = /*1*/ a | b;
|
||||||
type C5 = /*1*/ a | b;
|
type C5 = /*1*/ a | b;
|
||||||
type C6 /*0*/ = /*1*/ a | b;
|
type C6 /*0*/ = /*1*/ a | b;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,34 @@
|
|||||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||||
|
|
||||||
|
exports[`comments.ts format 1`] = `
|
||||||
|
====================================options=====================================
|
||||||
|
parsers: ["typescript"]
|
||||||
|
printWidth: 80 (default) |
|
||||||
|
=====================================input======================================
|
||||||
|
// https://github.com/prettier/prettier/issues/18834
|
||||||
|
type A1 = /* 1 */ | T1;
|
||||||
|
type A2 = /* 1 */ | (T2);
|
||||||
|
type A3 = (/* 1 */ | T3);
|
||||||
|
type A4 = /* 1 */ | /* 2 */ T4;
|
||||||
|
type A5 = /* 1 */ | (/* 2 */ T5);
|
||||||
|
type A6 = /* 0 */ /* 1 */ | /* 2 */ T6;
|
||||||
|
type A7 = /* 0 */ | /* 1 */ T7;
|
||||||
|
type A8 /* = */ /* 1:before */ = /* 2 */ | /* 3 */ T7;
|
||||||
|
|
||||||
|
=====================================output=====================================
|
||||||
|
// https://github.com/prettier/prettier/issues/18834
|
||||||
|
type A1 = /* 1 */ T1;
|
||||||
|
type A2 = /* 1 */ T2;
|
||||||
|
type A3 = /* 1 */ T3;
|
||||||
|
type A4 = /* 1 */ /* 2 */ T4;
|
||||||
|
type A5 = /* 1 */ /* 2 */ T5;
|
||||||
|
type A6 = /* 0 */ /* 1 */ /* 2 */ T6;
|
||||||
|
type A7 = /* 0 */ /* 1 */ T7;
|
||||||
|
type A8 /* = */ /* 1:before */ = /* 2 */ /* 3 */ T7;
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`single-type.ts format 1`] = `
|
exports[`single-type.ts format 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["typescript"]
|
parsers: ["typescript"]
|
||||||
@@ -13,9 +42,51 @@ type A1 =
|
|||||||
);
|
);
|
||||||
|
|
||||||
=====================================output=====================================
|
=====================================output=====================================
|
||||||
type A1 /* 2 */ = /* 1 */ /* 3 */ /* 4 */ {
|
type A1 = /* 1 */ /* 2 */ /* 3 */ /* 4 */ {
|
||||||
key: string;
|
key: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`single-type-2.ts format 1`] = `
|
||||||
|
====================================options=====================================
|
||||||
|
parsers: ["typescript"]
|
||||||
|
printWidth: 80 (default) |
|
||||||
|
=====================================input======================================
|
||||||
|
// https://github.com/oxc-project/oxc/pull/21915
|
||||||
|
export type myType = | // Comment
|
||||||
|
"A";
|
||||||
|
|
||||||
|
// Block comment same-line after pipe
|
||||||
|
type BlockComment = | /* block */
|
||||||
|
"B";
|
||||||
|
|
||||||
|
// Same-line comment then own-line comment
|
||||||
|
type Mixed = | // first
|
||||||
|
// second
|
||||||
|
"C";
|
||||||
|
|
||||||
|
// Long line comment that exceeds printWidth on the \`=\` line
|
||||||
|
type LongType = | // This is a really long comment that might exceed the print width limit
|
||||||
|
"A";
|
||||||
|
|
||||||
|
=====================================output=====================================
|
||||||
|
// https://github.com/oxc-project/oxc/pull/21915
|
||||||
|
export type myType = // Comment
|
||||||
|
"A";
|
||||||
|
|
||||||
|
// Block comment same-line after pipe
|
||||||
|
type BlockComment = /* block */ "B";
|
||||||
|
|
||||||
|
// Same-line comment then own-line comment
|
||||||
|
type Mixed = // first
|
||||||
|
// second
|
||||||
|
"C";
|
||||||
|
|
||||||
|
// Long line comment that exceeds printWidth on the \`=\` line
|
||||||
|
type LongType = // This is a really long comment that might exceed the print width limit
|
||||||
|
"A";
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
`;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// https://github.com/prettier/prettier/issues/18834
|
||||||
|
type A1 = /* 1 */ | T1;
|
||||||
|
type A2 = /* 1 */ | (T2);
|
||||||
|
type A3 = (/* 1 */ | T3);
|
||||||
|
type A4 = /* 1 */ | /* 2 */ T4;
|
||||||
|
type A5 = /* 1 */ | (/* 2 */ T5);
|
||||||
|
type A6 = /* 0 */ /* 1 */ | /* 2 */ T6;
|
||||||
|
type A7 = /* 0 */ | /* 1 */ T7;
|
||||||
|
type A8 /* = */ /* 1:before */ = /* 2 */ | /* 3 */ T7;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// https://github.com/oxc-project/oxc/pull/21915
|
||||||
|
export type myType = | // Comment
|
||||||
|
"A";
|
||||||
|
|
||||||
|
// Block comment same-line after pipe
|
||||||
|
type BlockComment = | /* block */
|
||||||
|
"B";
|
||||||
|
|
||||||
|
// Same-line comment then own-line comment
|
||||||
|
type Mixed = | // first
|
||||||
|
// second
|
||||||
|
"C";
|
||||||
|
|
||||||
|
// Long line comment that exceeds printWidth on the `=` line
|
||||||
|
type LongType = | // This is a really long comment that might exceed the print width limit
|
||||||
|
"A";
|
||||||
Reference in new issue
Block a user