diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index da411914dff..5e8da438663 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -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; diff --git a/tests/cases/fourslash/formatMultilineTypesWithMapped.ts b/tests/cases/fourslash/formatMultilineTypesWithMapped.ts new file mode 100644 index 00000000000..6ea46ca57c5 --- /dev/null +++ b/tests/cases/fourslash/formatMultilineTypesWithMapped.ts @@ -0,0 +1,76 @@ +/// + +//// 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 +}` +) \ No newline at end of file