|
| 1 | +--- |
| 2 | +source: crates/biome_formatter_test/src/snapshot_builder.rs |
| 3 | +info: ts/type/type_alias/issue-8774.ts |
| 4 | +--- |
| 5 | +# Input |
| 6 | + |
| 7 | +```ts |
| 8 | +// Test case 1: Basic type alias with extends and trailing comment |
| 9 | +type A<B, C extends D> = |
| 10 | + // Some comment |
| 11 | + undefined; |
| 12 | +
|
| 13 | +// Test case 2: Type alias with extends, comment after = on new line |
| 14 | +type A2<B, C extends D> = |
| 15 | + // Some comment |
| 16 | + undefined; |
| 17 | +
|
| 18 | +// Test case 3: Multiple type parameters with extends |
| 19 | +type E<F, G extends H, I extends J> = |
| 20 | + // Multiple comments |
| 21 | + // On multiple lines |
| 22 | + string; |
| 23 | +
|
| 24 | +// Test case 4: Type alias without extends (should work already) |
| 25 | +type K<L, M> = |
| 26 | + // Works without extends |
| 27 | + // Some comment |
| 28 | + undefined; |
| 29 | +
|
| 30 | +// Test case 5: Type alias with default value and comment |
| 31 | +type N<O extends P = Q> = |
| 32 | + // Comment with default value |
| 33 | + R; |
| 34 | +
|
| 35 | +// Test case 6: Type alias with both extends and default |
| 36 | +type S<T extends U = V, W extends X = Y> = |
| 37 | + // Comment with both extends and default |
| 38 | + Z; |
| 39 | +
|
| 40 | +// Test case 7: Complex right-hand side with extends and comment |
| 41 | +type AA<BB, CC extends DD> = |
| 42 | + // Comment before object type |
| 43 | + { |
| 44 | + property: string; |
| 45 | + }; |
| 46 | +
|
| 47 | +// Test case 8: Union type with extends and comment |
| 48 | +type EE<FF, GG extends HH> = |
| 49 | + // Comment before union |
| 50 | + | string |
| 51 | + | number |
| 52 | + | boolean; |
| 53 | +
|
| 54 | +// Test case 9: Conditional type with extends and comment |
| 55 | +type II<JJ, KK extends LL> = |
| 56 | + // Comment before conditional |
| 57 | + MM extends NN ? OO : PP; |
| 58 | +
|
| 59 | +// Test case 10: Type alias with multiple extends and long comment |
| 60 | +type QQ<RR extends SS, TT extends UU, VV extends WW> = |
| 61 | + // Very long comment that spans |
| 62 | + // multiple lines to test |
| 63 | + // proper indentation |
| 64 | + XX; |
| 65 | +
|
| 66 | +``` |
| 67 | +
|
| 68 | +
|
| 69 | +============================= |
| 70 | +
|
| 71 | +# Outputs |
| 72 | +
|
| 73 | +## Output 1 |
| 74 | +
|
| 75 | +----- |
| 76 | +Indent style: Tab |
| 77 | +Indent width: 2 |
| 78 | +Line ending: LF |
| 79 | +Line width: 80 |
| 80 | +Quote style: Double Quotes |
| 81 | +JSX quote style: Double Quotes |
| 82 | +Quote properties: As needed |
| 83 | +Trailing commas: All |
| 84 | +Semicolons: Always |
| 85 | +Arrow parentheses: Always |
| 86 | +Bracket spacing: true |
| 87 | +Bracket same line: false |
| 88 | +Attribute Position: Auto |
| 89 | +Expand lists: Auto |
| 90 | +Operator linebreak: After |
| 91 | +----- |
| 92 | +
|
| 93 | +```ts |
| 94 | +// Test case 1: Basic type alias with extends and trailing comment |
| 95 | +type A<B, C extends D> = |
| 96 | + // Some comment |
| 97 | + undefined; |
| 98 | +
|
| 99 | +// Test case 2: Type alias with extends, comment after = on new line |
| 100 | +type A2<B, C extends D> = |
| 101 | + // Some comment |
| 102 | + undefined; |
| 103 | +
|
| 104 | +// Test case 3: Multiple type parameters with extends |
| 105 | +type E<F, G extends H, I extends J> = |
| 106 | + // Multiple comments |
| 107 | + // On multiple lines |
| 108 | + string; |
| 109 | +
|
| 110 | +// Test case 4: Type alias without extends (should work already) |
| 111 | +type K<L, M> = |
| 112 | + // Works without extends |
| 113 | + // Some comment |
| 114 | + undefined; |
| 115 | +
|
| 116 | +// Test case 5: Type alias with default value and comment |
| 117 | +type N<O extends P = Q> = |
| 118 | + // Comment with default value |
| 119 | + R; |
| 120 | +
|
| 121 | +// Test case 6: Type alias with both extends and default |
| 122 | +type S<T extends U = V, W extends X = Y> = |
| 123 | + // Comment with both extends and default |
| 124 | + Z; |
| 125 | +
|
| 126 | +// Test case 7: Complex right-hand side with extends and comment |
| 127 | +type AA<BB, CC extends DD> = |
| 128 | + // Comment before object type |
| 129 | + { |
| 130 | + property: string; |
| 131 | + }; |
| 132 | +
|
| 133 | +// Test case 8: Union type with extends and comment |
| 134 | +type EE<FF, GG extends HH> = |
| 135 | + // Comment before union |
| 136 | + string | number | boolean; |
| 137 | +
|
| 138 | +// Test case 9: Conditional type with extends and comment |
| 139 | +type II<JJ, KK extends LL> = |
| 140 | + // Comment before conditional |
| 141 | + MM extends NN ? OO : PP; |
| 142 | +
|
| 143 | +// Test case 10: Type alias with multiple extends and long comment |
| 144 | +type QQ<RR extends SS, TT extends UU, VV extends WW> = |
| 145 | + // Very long comment that spans |
| 146 | + // multiple lines to test |
| 147 | + // proper indentation |
| 148 | + XX; |
| 149 | +``` |
0 commit comments