Merge pull request #24312 from Kingwl/multiline-type-literal-formatter
fix wrong formatting with multiline type literals with IntersectionTy…
This commit is contained in:
commit
9d57903630
|
@ -569,6 +569,12 @@ namespace ts.formatting {
|
|||
return childKind !== SyntaxKind.JsxClosingElement;
|
||||
case SyntaxKind.JsxFragment:
|
||||
return childKind !== SyntaxKind.JsxClosingFragment;
|
||||
case SyntaxKind.IntersectionType:
|
||||
case SyntaxKind.UnionType:
|
||||
if (childKind === SyntaxKind.TypeLiteral) {
|
||||
return false;
|
||||
}
|
||||
// falls through
|
||||
}
|
||||
// No explicit rule for given nodes so the result will follow the default value argument
|
||||
return indentByDefault;
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// type NumberAndString = {
|
||||
//// a: number
|
||||
//// } & {
|
||||
//// b: string
|
||||
//// };
|
||||
////
|
||||
//// type NumberOrString = {
|
||||
//// a: number
|
||||
//// } | {
|
||||
//// b: string
|
||||
//// };
|
||||
////
|
||||
//// type Complexed =
|
||||
//// Foo &
|
||||
//// Bar |
|
||||
//// Baz;
|
||||
|
||||
|
||||
format.document();
|
||||
verify.currentFileContentIs(`type NumberAndString = {
|
||||
a: number
|
||||
} & {
|
||||
b: string
|
||||
};
|
||||
|
||||
type NumberOrString = {
|
||||
a: number
|
||||
} | {
|
||||
b: string
|
||||
};
|
||||
|
||||
type Complexed =
|
||||
Foo &
|
||||
Bar |
|
||||
Baz;`);
|
Loading…
Reference in a new issue