From 32a9ec6c30652de28e1f38fb51580193ccb44c59 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 29 Jul 2018 15:25:54 -0700 Subject: [PATCH] Add tests --- .../types/mapped/mappedTypesArraysTuples.ts | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tests/cases/conformance/types/mapped/mappedTypesArraysTuples.ts diff --git a/tests/cases/conformance/types/mapped/mappedTypesArraysTuples.ts b/tests/cases/conformance/types/mapped/mappedTypesArraysTuples.ts new file mode 100644 index 00000000000..0607462fe04 --- /dev/null +++ b/tests/cases/conformance/types/mapped/mappedTypesArraysTuples.ts @@ -0,0 +1,65 @@ +// @strict: true +// @declaration: true + +type Box = { value: T }; +type Boxified = { [P in keyof T]: Box }; + +type T00 = Boxified<[number, string?, ...boolean[]]>; +type T01 = Partial<[number, string?, ...boolean[]]>; +type T02 = Required<[number, string?, ...boolean[]]>; + +type T10 = Boxified; +type T11 = Partial; +type T12 = Required; +type T13 = Boxified>; +type T14 = Partial>; +type T15 = Required>; + +type T20 = Boxified<(string | undefined)[]>; +type T21 = Partial<(string | undefined)[]>; +type T22 = Required<(string | undefined)[]>; +type T23 = Boxified>; +type T24 = Partial>; +type T25 = Required>; + +type T30 = Boxified>; +type T31 = Partial>; + +type A = { a: string }; +type B = { b: string }; + +type T40 = Boxified | [A, B] | string | string[]>; + +declare function unboxify(x: Boxified): T; + +declare let x10: [Box, Box, ...Box[]]; +let y10 = unboxify(x10); + +declare let x11: Box[]; +let y11 = unboxify(x11); + +declare let x12: { a: Box, b: Box }; +let y12 = unboxify(x12); + +declare function nonpartial(x: Partial): T; + +declare let x20: [number | undefined, string?, ...boolean[]]; +let y20 = nonpartial(x20); + +declare let x21: (number | undefined)[]; +let y21 = nonpartial(x21); + +declare let x22: { a: number | undefined, b?: string[] }; +let y22 = nonpartial(x22); + +type Awaited = T extends PromiseLike ? U : T; +type Awaitified = { [P in keyof T]: Awaited }; + +declare function all(...values: T): Promise>; + +function f1(a: number, b: Promise, c: string[], d: Promise) { + let x1 = all(a); + let x2 = all(a, b); + let x3 = all(a, b, c); + let x4 = all(a, b, c, d); +}