|
1 | 1 | === tests/cases/conformance/types/intersection/intersectionReduction.ts ===
|
2 |
| -// @strict |
3 |
| - |
4 | 2 | declare const sym1: unique symbol;
|
5 |
| ->sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) |
| 3 | +>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13)) |
6 | 4 |
|
7 | 5 | declare const sym2: unique symbol;
|
8 |
| ->sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 3, 13)) |
| 6 | +>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 1, 13)) |
9 | 7 |
|
10 | 8 | type T1 = string & 'a'; // 'a'
|
11 |
| ->T1 : Symbol(T1, Decl(intersectionReduction.ts, 3, 34)) |
| 9 | +>T1 : Symbol(T1, Decl(intersectionReduction.ts, 1, 34)) |
12 | 10 |
|
13 | 11 | type T2 = 'a' & string & 'b'; // never
|
14 |
| ->T2 : Symbol(T2, Decl(intersectionReduction.ts, 5, 23)) |
| 12 | +>T2 : Symbol(T2, Decl(intersectionReduction.ts, 3, 23)) |
15 | 13 |
|
16 | 14 | type T3 = number & 10; // 10
|
17 |
| ->T3 : Symbol(T3, Decl(intersectionReduction.ts, 6, 29)) |
| 15 | +>T3 : Symbol(T3, Decl(intersectionReduction.ts, 4, 29)) |
18 | 16 |
|
19 | 17 | type T4 = 10 & number & 20; // never
|
20 |
| ->T4 : Symbol(T4, Decl(intersectionReduction.ts, 7, 22)) |
| 18 | +>T4 : Symbol(T4, Decl(intersectionReduction.ts, 5, 22)) |
21 | 19 |
|
22 | 20 | type T5 = symbol & typeof sym1; // typeof sym1
|
23 |
| ->T5 : Symbol(T5, Decl(intersectionReduction.ts, 8, 27)) |
24 |
| ->sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) |
| 21 | +>T5 : Symbol(T5, Decl(intersectionReduction.ts, 6, 27)) |
| 22 | +>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13)) |
25 | 23 |
|
26 | 24 | type T6 = typeof sym1 & symbol & typeof sym2; // never
|
27 |
| ->T6 : Symbol(T6, Decl(intersectionReduction.ts, 9, 31)) |
28 |
| ->sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) |
29 |
| ->sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 3, 13)) |
| 25 | +>T6 : Symbol(T6, Decl(intersectionReduction.ts, 7, 31)) |
| 26 | +>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13)) |
| 27 | +>sym2 : Symbol(sym2, Decl(intersectionReduction.ts, 1, 13)) |
30 | 28 |
|
31 | 29 | type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never
|
32 |
| ->T7 : Symbol(T7, Decl(intersectionReduction.ts, 10, 45)) |
33 |
| ->sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 2, 13)) |
| 30 | +>T7 : Symbol(T7, Decl(intersectionReduction.ts, 8, 45)) |
| 31 | +>sym1 : Symbol(sym1, Decl(intersectionReduction.ts, 0, 13)) |
34 | 32 |
|
35 | 33 | type T10 = string & ('a' | 'b'); // 'a' | 'b'
|
36 |
| ->T10 : Symbol(T10, Decl(intersectionReduction.ts, 11, 60)) |
| 34 | +>T10 : Symbol(T10, Decl(intersectionReduction.ts, 9, 60)) |
37 | 35 |
|
38 | 36 | type T11 = (string | number) & ('a' | 10); // 'a' | 10
|
39 |
| ->T11 : Symbol(T11, Decl(intersectionReduction.ts, 13, 32)) |
| 37 | +>T11 : Symbol(T11, Decl(intersectionReduction.ts, 11, 32)) |
| 38 | + |
| 39 | +type N1 = 'a' & 'b'; |
| 40 | +>N1 : Symbol(N1, Decl(intersectionReduction.ts, 12, 42)) |
| 41 | + |
| 42 | +type N2 = { a: string } & null; |
| 43 | +>N2 : Symbol(N2, Decl(intersectionReduction.ts, 14, 20)) |
| 44 | +>a : Symbol(a, Decl(intersectionReduction.ts, 15, 11)) |
| 45 | + |
| 46 | +type N3 = { a: string } & undefined; |
| 47 | +>N3 : Symbol(N3, Decl(intersectionReduction.ts, 15, 31)) |
| 48 | +>a : Symbol(a, Decl(intersectionReduction.ts, 16, 11)) |
| 49 | + |
| 50 | +type N4 = string & number; |
| 51 | +>N4 : Symbol(N4, Decl(intersectionReduction.ts, 16, 36)) |
| 52 | + |
| 53 | +type N5 = number & object; |
| 54 | +>N5 : Symbol(N5, Decl(intersectionReduction.ts, 17, 26)) |
| 55 | + |
| 56 | +type N6 = symbol & string; |
| 57 | +>N6 : Symbol(N6, Decl(intersectionReduction.ts, 18, 26)) |
| 58 | + |
| 59 | +type N7 = void & string; |
| 60 | +>N7 : Symbol(N7, Decl(intersectionReduction.ts, 19, 26)) |
| 61 | + |
| 62 | +type X = { x: string }; |
| 63 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 64 | +>x : Symbol(x, Decl(intersectionReduction.ts, 22, 10)) |
| 65 | + |
| 66 | +type X1 = X | 'a' & 'b'; |
| 67 | +>X1 : Symbol(X1, Decl(intersectionReduction.ts, 22, 23)) |
| 68 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 69 | + |
| 70 | +type X2 = X | { a: string } & null; |
| 71 | +>X2 : Symbol(X2, Decl(intersectionReduction.ts, 24, 24)) |
| 72 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 73 | +>a : Symbol(a, Decl(intersectionReduction.ts, 25, 15)) |
| 74 | + |
| 75 | +type X3 = X | { a: string } & undefined; |
| 76 | +>X3 : Symbol(X3, Decl(intersectionReduction.ts, 25, 35)) |
| 77 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 78 | +>a : Symbol(a, Decl(intersectionReduction.ts, 26, 15)) |
| 79 | + |
| 80 | +type X4 = X | string & number; |
| 81 | +>X4 : Symbol(X4, Decl(intersectionReduction.ts, 26, 40)) |
| 82 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 83 | + |
| 84 | +type X5 = X | number & object; |
| 85 | +>X5 : Symbol(X5, Decl(intersectionReduction.ts, 27, 30)) |
| 86 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 87 | + |
| 88 | +type X6 = X | symbol & string; |
| 89 | +>X6 : Symbol(X6, Decl(intersectionReduction.ts, 28, 30)) |
| 90 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 91 | + |
| 92 | +type X7 = X | void & string; |
| 93 | +>X7 : Symbol(X7, Decl(intersectionReduction.ts, 29, 30)) |
| 94 | +>X : Symbol(X, Decl(intersectionReduction.ts, 20, 24)) |
| 95 | + |
| 96 | +// Repro from #31663 |
| 97 | + |
| 98 | +const x1 = { a: 'foo', b: 42 }; |
| 99 | +>x1 : Symbol(x1, Decl(intersectionReduction.ts, 34, 5)) |
| 100 | +>a : Symbol(a, Decl(intersectionReduction.ts, 34, 12)) |
| 101 | +>b : Symbol(b, Decl(intersectionReduction.ts, 34, 22)) |
| 102 | + |
| 103 | +const x2 = { a: 'foo', b: true }; |
| 104 | +>x2 : Symbol(x2, Decl(intersectionReduction.ts, 35, 5)) |
| 105 | +>a : Symbol(a, Decl(intersectionReduction.ts, 35, 12)) |
| 106 | +>b : Symbol(b, Decl(intersectionReduction.ts, 35, 22)) |
| 107 | + |
| 108 | +declare let k: 'a' | 'b'; |
| 109 | +>k : Symbol(k, Decl(intersectionReduction.ts, 37, 11)) |
| 110 | + |
| 111 | +x1[k] = 'bar' as any; // Error |
| 112 | +>x1 : Symbol(x1, Decl(intersectionReduction.ts, 34, 5)) |
| 113 | +>k : Symbol(k, Decl(intersectionReduction.ts, 37, 11)) |
| 114 | + |
| 115 | +x2[k] = 'bar' as any; // Error |
| 116 | +>x2 : Symbol(x2, Decl(intersectionReduction.ts, 35, 5)) |
| 117 | +>k : Symbol(k, Decl(intersectionReduction.ts, 37, 11)) |
| 118 | + |
| 119 | +const enum Tag1 {} |
| 120 | +>Tag1 : Symbol(Tag1, Decl(intersectionReduction.ts, 40, 21)) |
| 121 | + |
| 122 | +const enum Tag2 {} |
| 123 | +>Tag2 : Symbol(Tag2, Decl(intersectionReduction.ts, 42, 18)) |
| 124 | + |
| 125 | +declare let s1: string & Tag1; |
| 126 | +>s1 : Symbol(s1, Decl(intersectionReduction.ts, 45, 11)) |
| 127 | +>Tag1 : Symbol(Tag1, Decl(intersectionReduction.ts, 40, 21)) |
| 128 | + |
| 129 | +declare let s2: string & Tag2; |
| 130 | +>s2 : Symbol(s2, Decl(intersectionReduction.ts, 46, 11)) |
| 131 | +>Tag2 : Symbol(Tag2, Decl(intersectionReduction.ts, 42, 18)) |
| 132 | + |
| 133 | +declare let t1: string & Tag1 | undefined; |
| 134 | +>t1 : Symbol(t1, Decl(intersectionReduction.ts, 48, 11)) |
| 135 | +>Tag1 : Symbol(Tag1, Decl(intersectionReduction.ts, 40, 21)) |
| 136 | + |
| 137 | +declare let t2: string & Tag2 | undefined; |
| 138 | +>t2 : Symbol(t2, Decl(intersectionReduction.ts, 49, 11)) |
| 139 | +>Tag2 : Symbol(Tag2, Decl(intersectionReduction.ts, 42, 18)) |
| 140 | + |
| 141 | +s1 = s2; |
| 142 | +>s1 : Symbol(s1, Decl(intersectionReduction.ts, 45, 11)) |
| 143 | +>s2 : Symbol(s2, Decl(intersectionReduction.ts, 46, 11)) |
| 144 | + |
| 145 | +s2 = s1; |
| 146 | +>s2 : Symbol(s2, Decl(intersectionReduction.ts, 46, 11)) |
| 147 | +>s1 : Symbol(s1, Decl(intersectionReduction.ts, 45, 11)) |
| 148 | + |
| 149 | +t1 = t2; |
| 150 | +>t1 : Symbol(t1, Decl(intersectionReduction.ts, 48, 11)) |
| 151 | +>t2 : Symbol(t2, Decl(intersectionReduction.ts, 49, 11)) |
| 152 | + |
| 153 | +t2 = t1; |
| 154 | +>t2 : Symbol(t2, Decl(intersectionReduction.ts, 49, 11)) |
| 155 | +>t1 : Symbol(t1, Decl(intersectionReduction.ts, 48, 11)) |
40 | 156 |
|
0 commit comments