Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 55f2fd0

Browse files
committedMar 16, 2024·
Add tests
1 parent 5fb6593 commit 55f2fd0

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//// [tests/cases/compiler/mappedArrayTupleIntersections.ts] ////
2+
3+
=== mappedArrayTupleIntersections.ts ===
4+
type Box<T> = { value: T };
5+
>Box : Symbol(Box, Decl(mappedArrayTupleIntersections.ts, 0, 0))
6+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 0, 9))
7+
>value : Symbol(value, Decl(mappedArrayTupleIntersections.ts, 0, 15))
8+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 0, 9))
9+
10+
type Boxify<T> = { [K in keyof T]: Box<T[K]> };
11+
>Boxify : Symbol(Boxify, Decl(mappedArrayTupleIntersections.ts, 0, 27))
12+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 1, 12))
13+
>K : Symbol(K, Decl(mappedArrayTupleIntersections.ts, 1, 20))
14+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 1, 12))
15+
>Box : Symbol(Box, Decl(mappedArrayTupleIntersections.ts, 0, 0))
16+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 1, 12))
17+
>K : Symbol(K, Decl(mappedArrayTupleIntersections.ts, 1, 20))
18+
19+
type T1 = Boxify<string[]>;
20+
>T1 : Symbol(T1, Decl(mappedArrayTupleIntersections.ts, 1, 47))
21+
>Boxify : Symbol(Boxify, Decl(mappedArrayTupleIntersections.ts, 0, 27))
22+
23+
type T2 = Boxify<[string, string]>;
24+
>T2 : Symbol(T2, Decl(mappedArrayTupleIntersections.ts, 3, 27))
25+
>Boxify : Symbol(Boxify, Decl(mappedArrayTupleIntersections.ts, 0, 27))
26+
27+
type T3 = Boxify<string[] & unknown[]>;
28+
>T3 : Symbol(T3, Decl(mappedArrayTupleIntersections.ts, 4, 35))
29+
>Boxify : Symbol(Boxify, Decl(mappedArrayTupleIntersections.ts, 0, 27))
30+
31+
type T4 = Boxify<string[] & [string, string]>;
32+
>T4 : Symbol(T4, Decl(mappedArrayTupleIntersections.ts, 5, 39))
33+
>Boxify : Symbol(Boxify, Decl(mappedArrayTupleIntersections.ts, 0, 27))
34+
35+
type T5 = Boxify<string[] & { x: string }>;
36+
>T5 : Symbol(T5, Decl(mappedArrayTupleIntersections.ts, 6, 46))
37+
>Boxify : Symbol(Boxify, Decl(mappedArrayTupleIntersections.ts, 0, 27))
38+
>x : Symbol(x, Decl(mappedArrayTupleIntersections.ts, 7, 29))
39+
40+
// https://github.com/microsoft/TypeScript/issues/57744
41+
42+
type MustBeArray<T extends any[]> = T;
43+
>MustBeArray : Symbol(MustBeArray, Decl(mappedArrayTupleIntersections.ts, 7, 43))
44+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 11, 17))
45+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 11, 17))
46+
47+
type Hmm<T extends any[]> = T extends number[] ?
48+
>Hmm : Symbol(Hmm, Decl(mappedArrayTupleIntersections.ts, 11, 38))
49+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 13, 9))
50+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 13, 9))
51+
52+
MustBeArray<{ [I in keyof T]: 1 }> :
53+
>MustBeArray : Symbol(MustBeArray, Decl(mappedArrayTupleIntersections.ts, 7, 43))
54+
>I : Symbol(I, Decl(mappedArrayTupleIntersections.ts, 14, 19))
55+
>T : Symbol(T, Decl(mappedArrayTupleIntersections.ts, 13, 9))
56+
57+
never;
58+
59+
type X = Hmm<[3, 4, 5]>;
60+
>X : Symbol(X, Decl(mappedArrayTupleIntersections.ts, 15, 10))
61+
>Hmm : Symbol(Hmm, Decl(mappedArrayTupleIntersections.ts, 11, 38))
62+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//// [tests/cases/compiler/mappedArrayTupleIntersections.ts] ////
2+
3+
=== mappedArrayTupleIntersections.ts ===
4+
type Box<T> = { value: T };
5+
>Box : Box<T>
6+
>value : T
7+
8+
type Boxify<T> = { [K in keyof T]: Box<T[K]> };
9+
>Boxify : Boxify<T>
10+
11+
type T1 = Boxify<string[]>;
12+
>T1 : Box<string>[]
13+
14+
type T2 = Boxify<[string, string]>;
15+
>T2 : [Box<string>, Box<string>]
16+
17+
type T3 = Boxify<string[] & unknown[]>;
18+
>T3 : Box<string>[] & Box<unknown>[]
19+
20+
type T4 = Boxify<string[] & [string, string]>;
21+
>T4 : Box<string>[] & [Box<string>, Box<string>]
22+
23+
type T5 = Boxify<string[] & { x: string }>;
24+
>T5 : Boxify<string[] & { x: string; }>
25+
>x : string
26+
27+
// https://github.com/microsoft/TypeScript/issues/57744
28+
29+
type MustBeArray<T extends any[]> = T;
30+
>MustBeArray : T
31+
32+
type Hmm<T extends any[]> = T extends number[] ?
33+
>Hmm : Hmm<T>
34+
35+
MustBeArray<{ [I in keyof T]: 1 }> :
36+
never;
37+
38+
type X = Hmm<[3, 4, 5]>;
39+
>X : [1, 1, 1]
40+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @strict: true
2+
// @noEmit: true
3+
4+
type Box<T> = { value: T };
5+
type Boxify<T> = { [K in keyof T]: Box<T[K]> };
6+
7+
type T1 = Boxify<string[]>;
8+
type T2 = Boxify<[string, string]>;
9+
type T3 = Boxify<string[] & unknown[]>;
10+
type T4 = Boxify<string[] & [string, string]>;
11+
type T5 = Boxify<string[] & { x: string }>;
12+
13+
// https://github.com/microsoft/TypeScript/issues/57744
14+
15+
type MustBeArray<T extends any[]> = T;
16+
17+
type Hmm<T extends any[]> = T extends number[] ?
18+
MustBeArray<{ [I in keyof T]: 1 }> :
19+
never;
20+
21+
type X = Hmm<[3, 4, 5]>;

0 commit comments

Comments
 (0)
Please sign in to comment.