mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
fix51686: don't indent mapped types on new lines (#58039)
This commit is contained in:
parent
8e1144833c
commit
46b4c925c3
@ -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;
|
||||
|
||||
76
tests/cases/fourslash/formatMultilineTypesWithMapped.ts
Normal file
76
tests/cases/fourslash/formatMultilineTypesWithMapped.ts
Normal 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
|
||||
}`
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user