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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
=== tests/cases/conformance/types/intersection/intersectionTypeInference.ts ===
function extend<T, U>(obj1: T, obj2: U): T & U {
>extend : Symbol(extend, Decl(intersectionTypeInference.ts, 0, 0))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 0, 16))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 0, 18))
>obj1 : Symbol(obj1, Decl(intersectionTypeInference.ts, 0, 22))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 0, 16))
>obj2 : Symbol(obj2, Decl(intersectionTypeInference.ts, 0, 30))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 0, 18))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 0, 16))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 0, 18))
var result: T & U;
>result : Symbol(result, Decl(intersectionTypeInference.ts, 1, 7))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 0, 16))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 0, 18))
obj1 = result;
>obj1 : Symbol(obj1, Decl(intersectionTypeInference.ts, 0, 22))
>result : Symbol(result, Decl(intersectionTypeInference.ts, 1, 7))
obj2 = result;
>obj2 : Symbol(obj2, Decl(intersectionTypeInference.ts, 0, 30))
>result : Symbol(result, Decl(intersectionTypeInference.ts, 1, 7))
result = obj1; // Error
>result : Symbol(result, Decl(intersectionTypeInference.ts, 1, 7))
>obj1 : Symbol(obj1, Decl(intersectionTypeInference.ts, 0, 22))
result = obj2; // Error
>result : Symbol(result, Decl(intersectionTypeInference.ts, 1, 7))
>obj2 : Symbol(obj2, Decl(intersectionTypeInference.ts, 0, 30))
return result;
>result : Symbol(result, Decl(intersectionTypeInference.ts, 1, 7))
}
var x = extend({ a: "hello" }, { b: 42 });
>x : Symbol(x, Decl(intersectionTypeInference.ts, 9, 3))
>extend : Symbol(extend, Decl(intersectionTypeInference.ts, 0, 0))
>a : Symbol(a, Decl(intersectionTypeInference.ts, 9, 16))
>b : Symbol(b, Decl(intersectionTypeInference.ts, 9, 32))
var s = x.a;
>s : Symbol(s, Decl(intersectionTypeInference.ts, 10, 3))
>x.a : Symbol(a, Decl(intersectionTypeInference.ts, 9, 16))
>x : Symbol(x, Decl(intersectionTypeInference.ts, 9, 3))
>a : Symbol(a, Decl(intersectionTypeInference.ts, 9, 16))
var n = x.b;
>n : Symbol(n, Decl(intersectionTypeInference.ts, 11, 3))
>x.b : Symbol(b, Decl(intersectionTypeInference.ts, 9, 32))
>x : Symbol(x, Decl(intersectionTypeInference.ts, 9, 3))
>b : Symbol(b, Decl(intersectionTypeInference.ts, 9, 32))
interface A<T> {
>A : Symbol(A, Decl(intersectionTypeInference.ts, 11, 12))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 13, 12))
a: T;
>a : Symbol(A.a, Decl(intersectionTypeInference.ts, 13, 16))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 13, 12))
}
interface B<U> {
>B : Symbol(B, Decl(intersectionTypeInference.ts, 15, 1))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 17, 12))
b: U;
>b : Symbol(B.b, Decl(intersectionTypeInference.ts, 17, 16))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 17, 12))
}
function foo<T, U>(obj: A<T> & B<U>): T | U {
>foo : Symbol(foo, Decl(intersectionTypeInference.ts, 19, 1))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 21, 13))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 21, 15))
>obj : Symbol(obj, Decl(intersectionTypeInference.ts, 21, 19))
>A : Symbol(A, Decl(intersectionTypeInference.ts, 11, 12))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 21, 13))
>B : Symbol(B, Decl(intersectionTypeInference.ts, 15, 1))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 21, 15))
>T : Symbol(T, Decl(intersectionTypeInference.ts, 21, 13))
>U : Symbol(U, Decl(intersectionTypeInference.ts, 21, 15))
return undefined;
>undefined : Symbol(undefined)
}
var z = foo({ a: "hello", b: 42 });
>z : Symbol(z, Decl(intersectionTypeInference.ts, 25, 3), Decl(intersectionTypeInference.ts, 26, 3))
>foo : Symbol(foo, Decl(intersectionTypeInference.ts, 19, 1))
>a : Symbol(a, Decl(intersectionTypeInference.ts, 25, 13))
>b : Symbol(b, Decl(intersectionTypeInference.ts, 25, 25))
var z: string | number;
>z : Symbol(z, Decl(intersectionTypeInference.ts, 25, 3), Decl(intersectionTypeInference.ts, 26, 3))
|