|
1 | | -#### Fix the inconsistent printing between class and interface (#18094, #18091 by @fisker) |
| 1 | +#### Fix the inconsistent printing between class and interface (#18094, #18091, #18215 by @fisker) |
2 | 2 |
|
3 | 3 | ##### The extra indentation for type parameters in class has been removed |
4 | 4 |
|
@@ -72,6 +72,67 @@ export class AreaConfig<ES extends ExprRef | SignalRef> |
72 | 72 | implements MarkConfig<ES>, PointOverlayMixins<ES>, LineOverlayMixins<ES> {} |
73 | 73 | ``` |
74 | 74 |
|
| 75 | +##### Align single heritage print with super class |
| 76 | + |
| 77 | +<!-- prettier-ignore --> |
| 78 | +```tsx |
| 79 | +// Input |
| 80 | +class ExtendsLongOneWithGenerics |
| 81 | + extends |
| 82 | + Bar< |
| 83 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 84 | + ToBreakLineToBreakLineToBreakLine, |
| 85 | + > {} |
| 86 | +class ExtendsLongOneWithGenerics |
| 87 | + implements |
| 88 | + Bar< |
| 89 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 90 | + ToBreakLineToBreakLineToBreakLine, |
| 91 | + > {} |
| 92 | +interface ExtendsLongOneWithGenerics |
| 93 | + extends |
| 94 | + Bar< |
| 95 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 96 | + ToBreakLineToBreakLineToBreakLine, |
| 97 | + > {} |
| 98 | + |
| 99 | +// Prettier stable |
| 100 | +class ExtendsLongOneWithGenerics extends Bar< |
| 101 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 102 | + ToBreakLineToBreakLineToBreakLine |
| 103 | +> {} |
| 104 | +class ExtendsLongOneWithGenerics |
| 105 | + implements |
| 106 | + Bar< |
| 107 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 108 | + ToBreakLineToBreakLineToBreakLine |
| 109 | + > {} |
| 110 | +interface ExtendsLongOneWithGenerics |
| 111 | + extends Bar< |
| 112 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 113 | + ToBreakLineToBreakLineToBreakLine |
| 114 | + > {} |
| 115 | + |
| 116 | +// Prettier main |
| 117 | +interface Interface extends GenericEnvironment< |
| 118 | + SomeType, |
| 119 | + AnotherType, |
| 120 | + YetAnotherType |
| 121 | +> {} |
| 122 | +class ExtendsLongOneWithGenerics extends Bar< |
| 123 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 124 | + ToBreakLineToBreakLineToBreakLine |
| 125 | +> {} |
| 126 | +class ExtendsLongOneWithGenerics implements Bar< |
| 127 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 128 | + ToBreakLineToBreakLineToBreakLine |
| 129 | +> {} |
| 130 | +interface ExtendsLongOneWithGenerics extends Bar< |
| 131 | + SomeLongTypeSomeLongTypeSomeLongTypeSomeLongType, |
| 132 | + ToBreakLineToBreakLineToBreakLine |
| 133 | +> {} |
| 134 | +``` |
| 135 | + |
75 | 136 | ##### Inconsistent opening brace print logic of class and interface body |
76 | 137 |
|
77 | 138 | In Prettier v2.3, to improve visual separation between class head and body, [we start to print `{` of class body on a new line when the class has multiple heritages](https://prettier.io/blog/2021/05/09/2.3.0.html#improve-visual-separation-between-header-and-body-in-classes-with-multiline-headers-10085-by-sosukesuzuki). |
|
0 commit comments