mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
339 lines
15 KiB
Plaintext
339 lines
15 KiB
Plaintext
//// [tests/cases/conformance/types/intersection/intersectionReductionStrict.ts] ////
|
|
|
|
=== intersectionReductionStrict.ts ===
|
|
declare const sym1: unique symbol;
|
|
>sym1 : Symbol(sym1, Decl(intersectionReductionStrict.ts, 0, 13))
|
|
|
|
declare const sym2: unique symbol;
|
|
>sym2 : Symbol(sym2, Decl(intersectionReductionStrict.ts, 1, 13))
|
|
|
|
type T1 = string & 'a'; // 'a'
|
|
>T1 : Symbol(T1, Decl(intersectionReductionStrict.ts, 1, 34))
|
|
|
|
type T2 = 'a' & string & 'b'; // never
|
|
>T2 : Symbol(T2, Decl(intersectionReductionStrict.ts, 3, 23))
|
|
|
|
type T3 = number & 10; // 10
|
|
>T3 : Symbol(T3, Decl(intersectionReductionStrict.ts, 4, 29))
|
|
|
|
type T4 = 10 & number & 20; // never
|
|
>T4 : Symbol(T4, Decl(intersectionReductionStrict.ts, 5, 22))
|
|
|
|
type T5 = symbol & typeof sym1; // typeof sym1
|
|
>T5 : Symbol(T5, Decl(intersectionReductionStrict.ts, 6, 27))
|
|
>sym1 : Symbol(sym1, Decl(intersectionReductionStrict.ts, 0, 13))
|
|
|
|
type T6 = typeof sym1 & symbol & typeof sym2; // never
|
|
>T6 : Symbol(T6, Decl(intersectionReductionStrict.ts, 7, 31))
|
|
>sym1 : Symbol(sym1, Decl(intersectionReductionStrict.ts, 0, 13))
|
|
>sym2 : Symbol(sym2, Decl(intersectionReductionStrict.ts, 1, 13))
|
|
|
|
type T7 = string & 'a' & number & 10 & symbol & typeof sym1; // never
|
|
>T7 : Symbol(T7, Decl(intersectionReductionStrict.ts, 8, 45))
|
|
>sym1 : Symbol(sym1, Decl(intersectionReductionStrict.ts, 0, 13))
|
|
|
|
type T10 = string & ('a' | 'b'); // 'a' | 'b'
|
|
>T10 : Symbol(T10, Decl(intersectionReductionStrict.ts, 9, 60))
|
|
|
|
type T11 = (string | number) & ('a' | 10); // 'a' | 10
|
|
>T11 : Symbol(T11, Decl(intersectionReductionStrict.ts, 11, 32))
|
|
|
|
type N1 = 'a' & 'b';
|
|
>N1 : Symbol(N1, Decl(intersectionReductionStrict.ts, 12, 42))
|
|
|
|
type N2 = { a: string } & null;
|
|
>N2 : Symbol(N2, Decl(intersectionReductionStrict.ts, 14, 20))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 15, 11))
|
|
|
|
type N3 = { a: string } & undefined;
|
|
>N3 : Symbol(N3, Decl(intersectionReductionStrict.ts, 15, 31))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 16, 11))
|
|
|
|
type N4 = string & number;
|
|
>N4 : Symbol(N4, Decl(intersectionReductionStrict.ts, 16, 36))
|
|
|
|
type N5 = number & object;
|
|
>N5 : Symbol(N5, Decl(intersectionReductionStrict.ts, 17, 26))
|
|
|
|
type N6 = symbol & string;
|
|
>N6 : Symbol(N6, Decl(intersectionReductionStrict.ts, 18, 26))
|
|
|
|
type N7 = void & string;
|
|
>N7 : Symbol(N7, Decl(intersectionReductionStrict.ts, 19, 26))
|
|
|
|
type X = { x: string };
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
>x : Symbol(x, Decl(intersectionReductionStrict.ts, 22, 10))
|
|
|
|
type X1 = X | 'a' & 'b';
|
|
>X1 : Symbol(X1, Decl(intersectionReductionStrict.ts, 22, 23))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
|
|
type X2 = X | { a: string } & null;
|
|
>X2 : Symbol(X2, Decl(intersectionReductionStrict.ts, 24, 24))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 25, 15))
|
|
|
|
type X3 = X | { a: string } & undefined;
|
|
>X3 : Symbol(X3, Decl(intersectionReductionStrict.ts, 25, 35))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 26, 15))
|
|
|
|
type X4 = X | string & number;
|
|
>X4 : Symbol(X4, Decl(intersectionReductionStrict.ts, 26, 40))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
|
|
type X5 = X | number & object;
|
|
>X5 : Symbol(X5, Decl(intersectionReductionStrict.ts, 27, 30))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
|
|
type X6 = X | symbol & string;
|
|
>X6 : Symbol(X6, Decl(intersectionReductionStrict.ts, 28, 30))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
|
|
type X7 = X | void & string;
|
|
>X7 : Symbol(X7, Decl(intersectionReductionStrict.ts, 29, 30))
|
|
>X : Symbol(X, Decl(intersectionReductionStrict.ts, 20, 24))
|
|
|
|
type A = { kind: 'a', foo: string };
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>kind : Symbol(kind, Decl(intersectionReductionStrict.ts, 32, 10))
|
|
>foo : Symbol(foo, Decl(intersectionReductionStrict.ts, 32, 21))
|
|
|
|
type B = { kind: 'b', foo: number };
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
>kind : Symbol(kind, Decl(intersectionReductionStrict.ts, 33, 10))
|
|
>foo : Symbol(foo, Decl(intersectionReductionStrict.ts, 33, 21))
|
|
|
|
type C = { kind: 'c', foo: number };
|
|
>C : Symbol(C, Decl(intersectionReductionStrict.ts, 33, 36))
|
|
>kind : Symbol(kind, Decl(intersectionReductionStrict.ts, 34, 10))
|
|
>foo : Symbol(foo, Decl(intersectionReductionStrict.ts, 34, 21))
|
|
|
|
declare let ab: A & B;
|
|
>ab : Symbol(ab, Decl(intersectionReductionStrict.ts, 36, 11))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
ab.kind; // Error
|
|
>ab : Symbol(ab, Decl(intersectionReductionStrict.ts, 36, 11))
|
|
|
|
declare let x: A | (B & C); // A
|
|
>x : Symbol(x, Decl(intersectionReductionStrict.ts, 39, 11))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
>C : Symbol(C, Decl(intersectionReductionStrict.ts, 33, 36))
|
|
|
|
let a: A = x;
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 40, 3))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>x : Symbol(x, Decl(intersectionReductionStrict.ts, 39, 11))
|
|
|
|
type AB = A & B; // never
|
|
>AB : Symbol(AB, Decl(intersectionReductionStrict.ts, 40, 13))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
type BC = B & C; // never
|
|
>BC : Symbol(BC, Decl(intersectionReductionStrict.ts, 42, 16))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
>C : Symbol(C, Decl(intersectionReductionStrict.ts, 33, 36))
|
|
|
|
type U1 = Partial<A & B>; // never
|
|
>U1 : Symbol(U1, Decl(intersectionReductionStrict.ts, 43, 16))
|
|
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
type U2 = Readonly<A & B>; // never
|
|
>U2 : Symbol(U2, Decl(intersectionReductionStrict.ts, 45, 25))
|
|
>Readonly : Symbol(Readonly, Decl(lib.es5.d.ts, --, --))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
type U3 = (A & B)['kind']; // never
|
|
>U3 : Symbol(U3, Decl(intersectionReductionStrict.ts, 46, 26))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
type U4 = A & B | B & C; // never
|
|
>U4 : Symbol(U4, Decl(intersectionReductionStrict.ts, 47, 26))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
>C : Symbol(C, Decl(intersectionReductionStrict.ts, 33, 36))
|
|
|
|
type U5 = A | B & C; // A
|
|
>U5 : Symbol(U5, Decl(intersectionReductionStrict.ts, 48, 24))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
>C : Symbol(C, Decl(intersectionReductionStrict.ts, 33, 36))
|
|
|
|
type K1 = keyof (A & B); // string | number | symbol
|
|
>K1 : Symbol(K1, Decl(intersectionReductionStrict.ts, 49, 20))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
type K2 = keyof A | keyof B; // 'kind' | 'foo'
|
|
>K2 : Symbol(K2, Decl(intersectionReductionStrict.ts, 51, 24))
|
|
>A : Symbol(A, Decl(intersectionReductionStrict.ts, 30, 28))
|
|
>B : Symbol(B, Decl(intersectionReductionStrict.ts, 32, 36))
|
|
|
|
type Merge1<T, U> = { [P in keyof (T & U)]: P extends keyof T ? T[P] : U[P & keyof U] }
|
|
>Merge1 : Symbol(Merge1, Decl(intersectionReductionStrict.ts, 52, 28))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 54, 12))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 54, 14))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 54, 23))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 54, 12))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 54, 14))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 54, 23))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 54, 12))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 54, 12))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 54, 23))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 54, 14))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 54, 23))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 54, 14))
|
|
|
|
type Merge2<T, U> = { [P in keyof T | keyof U]: P extends keyof T ? T[P] : U[P & keyof U] }
|
|
>Merge2 : Symbol(Merge2, Decl(intersectionReductionStrict.ts, 54, 87))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 55, 12))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 55, 14))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 55, 23))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 55, 12))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 55, 14))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 55, 23))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 55, 12))
|
|
>T : Symbol(T, Decl(intersectionReductionStrict.ts, 55, 12))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 55, 23))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 55, 14))
|
|
>P : Symbol(P, Decl(intersectionReductionStrict.ts, 55, 23))
|
|
>U : Symbol(U, Decl(intersectionReductionStrict.ts, 55, 14))
|
|
|
|
type M1 = { a: 1, b: 2 } & { a: 2, c: 3 }; // never
|
|
>M1 : Symbol(M1, Decl(intersectionReductionStrict.ts, 55, 91))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 57, 11))
|
|
>b : Symbol(b, Decl(intersectionReductionStrict.ts, 57, 17))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 57, 28))
|
|
>c : Symbol(c, Decl(intersectionReductionStrict.ts, 57, 34))
|
|
|
|
type M2 = Merge1<{ a: 1, b: 2 }, { a: 2, c: 3 }>; // {}
|
|
>M2 : Symbol(M2, Decl(intersectionReductionStrict.ts, 57, 42))
|
|
>Merge1 : Symbol(Merge1, Decl(intersectionReductionStrict.ts, 52, 28))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 58, 18))
|
|
>b : Symbol(b, Decl(intersectionReductionStrict.ts, 58, 24))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 58, 34))
|
|
>c : Symbol(c, Decl(intersectionReductionStrict.ts, 58, 40))
|
|
|
|
type M3 = Merge2<{ a: 1, b: 2 }, { a: 2, c: 3 }>; // { a: 1, b: 2, c: 3 }
|
|
>M3 : Symbol(M3, Decl(intersectionReductionStrict.ts, 58, 49))
|
|
>Merge2 : Symbol(Merge2, Decl(intersectionReductionStrict.ts, 54, 87))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 59, 18))
|
|
>b : Symbol(b, Decl(intersectionReductionStrict.ts, 59, 24))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 59, 34))
|
|
>c : Symbol(c, Decl(intersectionReductionStrict.ts, 59, 40))
|
|
|
|
// Repro from #31663
|
|
|
|
const x1 = { a: 'foo', b: 42 };
|
|
>x1 : Symbol(x1, Decl(intersectionReductionStrict.ts, 63, 5))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 63, 12))
|
|
>b : Symbol(b, Decl(intersectionReductionStrict.ts, 63, 22))
|
|
|
|
const x2 = { a: 'foo', b: true };
|
|
>x2 : Symbol(x2, Decl(intersectionReductionStrict.ts, 64, 5))
|
|
>a : Symbol(a, Decl(intersectionReductionStrict.ts, 64, 12))
|
|
>b : Symbol(b, Decl(intersectionReductionStrict.ts, 64, 22))
|
|
|
|
declare let k: 'a' | 'b';
|
|
>k : Symbol(k, Decl(intersectionReductionStrict.ts, 66, 11))
|
|
|
|
x1[k] = 'bar' as any; // Error
|
|
>x1 : Symbol(x1, Decl(intersectionReductionStrict.ts, 63, 5))
|
|
>k : Symbol(k, Decl(intersectionReductionStrict.ts, 66, 11))
|
|
|
|
x2[k] = 'bar' as any; // Error
|
|
>x2 : Symbol(x2, Decl(intersectionReductionStrict.ts, 64, 5))
|
|
>k : Symbol(k, Decl(intersectionReductionStrict.ts, 66, 11))
|
|
|
|
const enum Tag1 {}
|
|
>Tag1 : Symbol(Tag1, Decl(intersectionReductionStrict.ts, 69, 21))
|
|
|
|
const enum Tag2 {}
|
|
>Tag2 : Symbol(Tag2, Decl(intersectionReductionStrict.ts, 71, 18))
|
|
|
|
declare let s1: string & Tag1;
|
|
>s1 : Symbol(s1, Decl(intersectionReductionStrict.ts, 74, 11))
|
|
>Tag1 : Symbol(Tag1, Decl(intersectionReductionStrict.ts, 69, 21))
|
|
|
|
declare let s2: string & Tag2;
|
|
>s2 : Symbol(s2, Decl(intersectionReductionStrict.ts, 75, 11))
|
|
>Tag2 : Symbol(Tag2, Decl(intersectionReductionStrict.ts, 71, 18))
|
|
|
|
declare let t1: string & Tag1 | undefined;
|
|
>t1 : Symbol(t1, Decl(intersectionReductionStrict.ts, 77, 11))
|
|
>Tag1 : Symbol(Tag1, Decl(intersectionReductionStrict.ts, 69, 21))
|
|
|
|
declare let t2: string & Tag2 | undefined;
|
|
>t2 : Symbol(t2, Decl(intersectionReductionStrict.ts, 78, 11))
|
|
>Tag2 : Symbol(Tag2, Decl(intersectionReductionStrict.ts, 71, 18))
|
|
|
|
s1 = s2;
|
|
>s1 : Symbol(s1, Decl(intersectionReductionStrict.ts, 74, 11))
|
|
>s2 : Symbol(s2, Decl(intersectionReductionStrict.ts, 75, 11))
|
|
|
|
s2 = s1;
|
|
>s2 : Symbol(s2, Decl(intersectionReductionStrict.ts, 75, 11))
|
|
>s1 : Symbol(s1, Decl(intersectionReductionStrict.ts, 74, 11))
|
|
|
|
t1 = t2;
|
|
>t1 : Symbol(t1, Decl(intersectionReductionStrict.ts, 77, 11))
|
|
>t2 : Symbol(t2, Decl(intersectionReductionStrict.ts, 78, 11))
|
|
|
|
t2 = t1;
|
|
>t2 : Symbol(t2, Decl(intersectionReductionStrict.ts, 78, 11))
|
|
>t1 : Symbol(t1, Decl(intersectionReductionStrict.ts, 77, 11))
|
|
|
|
// Repro from #36736
|
|
|
|
const f1 = (t: "a" | ("b" & "c")): "a" => t;
|
|
>f1 : Symbol(f1, Decl(intersectionReductionStrict.ts, 88, 5))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 88, 12))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 88, 12))
|
|
|
|
type Container<Type extends string> = {
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>Type : Symbol(Type, Decl(intersectionReductionStrict.ts, 90, 15))
|
|
|
|
type: Type;
|
|
>type : Symbol(type, Decl(intersectionReductionStrict.ts, 90, 39))
|
|
>Type : Symbol(Type, Decl(intersectionReductionStrict.ts, 90, 15))
|
|
}
|
|
|
|
const f2 = (t: Container<"a"> | (Container<"b"> & Container<"c">)): Container<"a"> => t;
|
|
>f2 : Symbol(f2, Decl(intersectionReductionStrict.ts, 94, 5))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 94, 12))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 94, 12))
|
|
|
|
const f3 = (t: Container<"a"> | (Container<"b"> & { dataB: boolean } & Container<"a">)): Container<"a"> => t;
|
|
>f3 : Symbol(f3, Decl(intersectionReductionStrict.ts, 95, 5))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 95, 12))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>dataB : Symbol(dataB, Decl(intersectionReductionStrict.ts, 95, 51))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 95, 12))
|
|
|
|
const f4 = (t: number | (Container<"b"> & { dataB: boolean } & Container<"a">)): number => t;
|
|
>f4 : Symbol(f4, Decl(intersectionReductionStrict.ts, 96, 5))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 96, 12))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>dataB : Symbol(dataB, Decl(intersectionReductionStrict.ts, 96, 43))
|
|
>Container : Symbol(Container, Decl(intersectionReductionStrict.ts, 88, 44))
|
|
>t : Symbol(t, Decl(intersectionReductionStrict.ts, 96, 12))
|
|
|