fix51686: don't indent mapped types on new lines (#58039)

This commit is contained in:
Isabel Duan 2024-04-02 15:52:09 -07:00 committed by GitHub
parent 8e1144833c
commit 46b4c925c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 78 additions and 1 deletions

View File

@ -721,7 +721,8 @@ export namespace SmartIndenter {
return childKind !== SyntaxKind.JsxClosingFragment;
case SyntaxKind.IntersectionType:
case SyntaxKind.UnionType:
if (childKind === SyntaxKind.TypeLiteral || childKind === SyntaxKind.TupleType) {
case SyntaxKind.SatisfiesExpression:
if (childKind === SyntaxKind.TypeLiteral || childKind === SyntaxKind.TupleType || childKind === SyntaxKind.MappedType) {
return false;
}
break;

View File

@ -0,0 +1,76 @@
/// <reference path="fourslash.ts" />
//// type Z = 'z'
//// type A = {
//// a: 'a'
//// } | {
//// [index in Z]: string
//// }
//// type B = {
//// b: 'b'
//// } & {
//// [index in Z]: string
//// }
////
//// const c = {
//// c: 'c'
//// } as const satisfies {
//// [index in Z]: string
//// }
////
//// const d = {
//// d: 'd'
//// } as const satisfies {
//// [index: string]: string
//// }
////
//// const e = {
//// e: 'e'
//// } satisfies {
//// [index in Z]: string
//// }
////
//// const f = {
//// f: 'f'
//// } satisfies {
//// [index: string]: string
//// }
format.document();
verify.currentFileContentIs(
`type Z = 'z'
type A = {
a: 'a'
} | {
[index in Z]: string
}
type B = {
b: 'b'
} & {
[index in Z]: string
}
const c = {
c: 'c'
} as const satisfies {
[index in Z]: string
}
const d = {
d: 'd'
} as const satisfies {
[index: string]: string
}
const e = {
e: 'e'
} satisfies {
[index in Z]: string
}
const f = {
f: 'f'
} satisfies {
[index: string]: string
}`
)