-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathmappedArrayTupleIntersections.types
More file actions
52 lines (39 loc) · 1.16 KB
/
mappedArrayTupleIntersections.types
File metadata and controls
52 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//// [tests/cases/compiler/mappedArrayTupleIntersections.ts] ////
=== mappedArrayTupleIntersections.ts ===
type Box<T> = { value: T };
>Box : Box<T>
> : ^^^^^^
>value : T
> : ^
type Boxify<T> = { [K in keyof T]: Box<T[K]> };
>Boxify : Boxify<T>
> : ^^^^^^^^^
type T1 = Boxify<string[]>;
>T1 : Box<string>[]
> : ^^^^^^^^^^^^^
type T2 = Boxify<[string, string]>;
>T2 : [Box<string>, Box<string>]
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^
type T3 = Boxify<string[] & unknown[]>;
>T3 : Box<string>[] & Box<unknown>[]
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
type T4 = Boxify<string[] & [string, string]>;
>T4 : Box<string>[] & [Box<string>, Box<string>]
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
type T5 = Boxify<string[] & { x: string }>;
>T5 : Box<string>[]
> : ^^^^^^^^^^^^^
>x : string
> : ^^^^^^
// https://github.com/microsoft/TypeScript/issues/57744
type MustBeArray<T extends any[]> = T;
>MustBeArray : T
> : ^
type Hmm<T extends any[]> = T extends number[] ?
>Hmm : Hmm<T>
> : ^^^^^^
MustBeArray<{ [I in keyof T]: 1 }> :
never;
type X = Hmm<[3, 4, 5]>;
>X : [1, 1, 1]
> : ^^^^^^^^^