diff --git a/tests/cases/conformance/types/mapped/mappedTypeModifiers.ts b/tests/cases/conformance/types/mapped/mappedTypeModifiers.ts index 1e76c5b745284..30aa652f0d9c0 100644 --- a/tests/cases/conformance/types/mapped/mappedTypeModifiers.ts +++ b/tests/cases/conformance/types/mapped/mappedTypeModifiers.ts @@ -1,85 +1,71 @@ // @strictNullChecks: true type T = { a: number, b: string }; -type TU = { a: number | undefined, b: string | undefined }; type TP = { a?: number, b?: string }; type TR = { readonly a: number, readonly b: string }; type TPR = { readonly a?: number, readonly b?: string }; -// Validate they all have the same keys var v00: "a" | "b"; var v00: keyof T; -var v00: keyof TU; var v00: keyof TP; var v00: keyof TR; var v00: keyof TPR; -// Validate that non-isomorphic mapped types strip modifiers var v01: T; -var v01: Pick; -var v01: Pick, keyof T>; +var v01: { [P in keyof T]: T[P] }; +var v01: Pick; +var v01: Pick, keyof T>; -// Validate that non-isomorphic mapped types strip modifiers -var v02: TU; +var v02: TP; +var v02: { [P in keyof T]?: T[P] }; +var v02: Partial; var v02: Pick; -var v02: Pick; -var v02: Pick, keyof T>; -var v02: Pick>, keyof T>; -// Validate that isomorphic mapped types preserve optional modifier -var v03: TP; -var v03: Partial; +var v03: TR; +var v03: { readonly [P in keyof T]: T[P] }; +var v03: Readonly; +var v03: Pick; -// Validate that isomorphic mapped types preserve readonly modifier -var v04: TR; -var v04: Readonly; - -// Validate that isomorphic mapped types preserve both partial and readonly modifiers -var v05: TPR; -var v05: Partial; -var v05: Readonly; -var v05: Partial>; -var v05: Readonly>; +var v04: TPR; +var v04: { readonly [P in keyof T]?: T[P] }; +var v04: Partial; +var v04: Readonly; +var v04: Partial>; +var v04: Readonly>; +var v04: Pick; type Boxified = { [P in keyof T]: { x: T[P] } }; type B = { a: { x: number }, b: { x: string } }; -type BU = { a: { x: number } | undefined, b: { x: string } | undefined }; type BP = { a?: { x: number }, b?: { x: string } }; type BR = { readonly a: { x: number }, readonly b: { x: string } }; type BPR = { readonly a?: { x: number }, readonly b?: { x: string } }; -// Validate they all have the same keys var b00: "a" | "b"; var b00: keyof B; -var b00: keyof BU; var b00: keyof BP; var b00: keyof BR; var b00: keyof BPR; -// Validate that non-isomorphic mapped types strip modifiers var b01: B; -var b01: Pick; -var b01: Pick, keyof B>; +var b01: { [P in keyof B]: B[P] }; +var b01: Pick; +var b01: Pick, keyof B>; -// Validate that non-isomorphic mapped types strip modifiers -var b02: BU; +var b02: BP; +var b02: { [P in keyof B]?: B[P] }; +var b02: Partial; var b02: Pick; -var b02: Pick; -var b02: Pick, keyof B>; -var b02: Pick>, keyof B>; - -// Validate that isomorphic mapped types preserve optional modifier -var b03: BP; -var b03: Partial; -// Validate that isomorphic mapped types preserve readonly modifier -var b04: BR; -var b04: Readonly; +var b03: BR; +var b03: { readonly [P in keyof B]: B[P] }; +var b03: Readonly; +var b03: Pick; -// Validate that isomorphic mapped types preserve both partial and readonly modifiers -var b05: BPR; -var b05: Partial
; -var b05: Readonly; -var b05: Partial>; -var b05: Readonly>; \ No newline at end of file +var b04: BPR; +var b04: { readonly [P in keyof B]?: B[P] }; +var b04: Partial
; +var b04: Readonly; +var b04: Partial>; +var b04: Readonly>; +var b04: Pick; \ No newline at end of file