Fix comment moved into brackets in object type members (#19698)

This commit is contained in:
Konv Suu authored and GitHub committed 2026-07-30 11:22:46 +08:00
1 parent d3e068e794
commit c081af8c65
11 files changed
+356 -43

No files matched your search

@@ -302,6 +302,69 @@ type Props3 = {
================================================================================
`;
exports[`object_type_indexer.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80 (default) |
=====================================input======================================
type A = {
[key: string]: /** Comment */ B,
};
type A = {
[key: string]: /** Comment */
B,
};
type A = {
[key: string] /** Comment */
: B,
};
type A = {
[key: string]: /** Comment */ | B,
};
type A = {
[key: string] /** Comment */: B | C,
};
type A = {
[key: string]: // Comment
| B
| C,
};
=====================================output=====================================
type A = {
[key: string]: /** Comment */ B,
};
type A = {
[key: string]: /** Comment */ B,
};
type A = {
[key: string /** Comment */]: B,
};
type A = {
[key: string]: /** Comment */ B,
};
type A = {
[key: string /** Comment */]: B | C,
};
type A = {
[key: string]:
// Comment
B | C,
};
================================================================================
`;
exports[`type_annotations.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
@@ -0,0 +1,27 @@
type A = {
[key: string]: /** Comment */ B,
};
type A = {
[key: string]: /** Comment */
B,
};
type A = {
[key: string] /** Comment */
: B,
};
type A = {
[key: string]: /** Comment */ | B,
};
type A = {
[key: string] /** Comment */: B | C,
};
type A = {
[key: string]: // Comment
| B
| C,
};
@@ -1,5 +1,68 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`comments.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80 (default) |
=====================================input======================================
type A = {
[[slot]]: /** Comment */ B,
};
type A = {
[[slot]]: /** Comment */
B,
};
type A = {
[[slot]] /** Comment */
: B,
};
type A = {
[[slot]]: /** Comment */ | B,
};
type A = {
[[slot]] /** Comment */: B | C,
};
type A = {
[[slot]]: // Comment
| B
| C,
};
=====================================output=====================================
type A = {
[[slot]]: /** Comment */ B,
};
type A = {
[[slot]]: /** Comment */ B,
};
type A = {
[[slot /** Comment */]]: B,
};
type A = {
[[slot]]: /** Comment */ B,
};
type A = {
[[slot /** Comment */]]: B | C,
};
type A = {
[[slot]]:
// Comment
B | C,
};
================================================================================
`;
exports[`internal_slot.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
@@ -0,0 +1,27 @@
type A = {
[[slot]]: /** Comment */ B,
};
type A = {
[[slot]]: /** Comment */
B,
};
type A = {
[[slot]] /** Comment */
: B,
};
type A = {
[[slot]]: /** Comment */ | B,
};
type A = {
[[slot]] /** Comment */: B | C,
};
type A = {
[[slot]]: // Comment
| B
| C,
};
@@ -46,6 +46,17 @@ type Type = {
/* bar */ [T in number]: number;
};
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = {
[K in keyof T]: /** Comment */
B,
};
type Type<T> = { [K in keyof T]: /** Comment */ | B };
type Type<T> = { [K in keyof T] /** Comment */: B | C };
=====================================output=====================================
type Type = {
// comment
@@ -87,6 +98,16 @@ type Type = {
+[/* bar */ T in number]: number, // foo
};
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = {
[K in keyof T]: /** Comment */ B,
};
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = { [K in keyof T /** Comment */]: B | C };
================================================================================
`;
@@ -38,3 +38,14 @@ type Type = {
+ // foo
/* bar */ [T in number]: number;
};
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = {
[K in keyof T]: /** Comment */
B,
};
type Type<T> = { [K in keyof T]: /** Comment */ | B };
type Type<T> = { [K in keyof T] /** Comment */: B | C };
@@ -1,5 +1,57 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`comments.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80 (default) |
=====================================input======================================
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = {
[K in keyof T]: /** Comment */
B;
};
type Type<T> = { [K in keyof T]: /** Comment */ | B };
type Type<T> = { [K in keyof T] /** Comment */: B | C };
type Type<T> = { [K in keyof T as \`get\${K}\`]: /** Comment */ B };
type Type<T> = { [K in keyof T as \`get\${K}\`]: /** Comment */ | B };
type Type<T> = { [K in keyof T as K extends string ? K : never]: /** Comment */ B };
type Type<T> = {
[K in keyof T as K extends string ? K : never] /** Comment */: B | C;
};
=====================================output=====================================
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = {
[K in keyof T]: /** Comment */ B;
};
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = { [K in keyof T /** Comment */]: B | C };
type Type<T> = { [K in keyof T as \`get\${K}\`]: /** Comment */ B };
type Type<T> = { [K in keyof T as \`get\${K}\`]: /** Comment */ B };
type Type<T> = {
[K in keyof T as K extends string ? K : never]: /** Comment */ B;
};
type Type<T> = {
[K in keyof T as K extends string ? K : never /** Comment */]: B | C;
};
================================================================================
`;
exports[`intersection.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
@@ -0,0 +1,20 @@
type Type<T> = { [K in keyof T]: /** Comment */ B };
type Type<T> = {
[K in keyof T]: /** Comment */
B;
};
type Type<T> = { [K in keyof T]: /** Comment */ | B };
type Type<T> = { [K in keyof T] /** Comment */: B | C };
type Type<T> = { [K in keyof T as `get${K}`]: /** Comment */ B };
type Type<T> = { [K in keyof T as `get${K}`]: /** Comment */ | B };
type Type<T> = { [K in keyof T as K extends string ? K : never]: /** Comment */ B };
type Type<T> = {
[K in keyof T as K extends string ? K : never] /** Comment */: B | C;
};