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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgs2.ts ===
class Base {
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
x: string;
>x : Symbol(Base.x, Decl(genericCallWithObjectTypeArgs2.ts, 0, 12))
}
class Derived extends Base {
>Derived : Symbol(Derived, Decl(genericCallWithObjectTypeArgs2.ts, 2, 1))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
y: string;
>y : Symbol(Derived.y, Decl(genericCallWithObjectTypeArgs2.ts, 3, 28))
}
class Derived2 extends Base {
>Derived2 : Symbol(Derived2, Decl(genericCallWithObjectTypeArgs2.ts, 5, 1))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
z: string;
>z : Symbol(Derived2.z, Decl(genericCallWithObjectTypeArgs2.ts, 6, 29))
}
// returns {}[]
function f<T extends Base, U extends Base>(a: { x: T; y: U }) {
>f : Symbol(f, Decl(genericCallWithObjectTypeArgs2.ts, 8, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 11, 11))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
>U : Symbol(U, Decl(genericCallWithObjectTypeArgs2.ts, 11, 26))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithObjectTypeArgs2.ts, 11, 43))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 11, 47))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 11, 11))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 11, 53))
>U : Symbol(U, Decl(genericCallWithObjectTypeArgs2.ts, 11, 26))
return [a.x, a.y];
>a.x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 11, 47))
>a : Symbol(a, Decl(genericCallWithObjectTypeArgs2.ts, 11, 43))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 11, 47))
>a.y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 11, 53))
>a : Symbol(a, Decl(genericCallWithObjectTypeArgs2.ts, 11, 43))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 11, 53))
}
var r = f({ x: new Derived(), y: new Derived2() }); // {}[]
>r : Symbol(r, Decl(genericCallWithObjectTypeArgs2.ts, 15, 3))
>f : Symbol(f, Decl(genericCallWithObjectTypeArgs2.ts, 8, 1))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 15, 11))
>Derived : Symbol(Derived, Decl(genericCallWithObjectTypeArgs2.ts, 2, 1))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 15, 29))
>Derived2 : Symbol(Derived2, Decl(genericCallWithObjectTypeArgs2.ts, 5, 1))
var r2 = f({ x: new Base(), y: new Derived2() }); // {}[]
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgs2.ts, 16, 3))
>f : Symbol(f, Decl(genericCallWithObjectTypeArgs2.ts, 8, 1))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 16, 12))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 16, 27))
>Derived2 : Symbol(Derived2, Decl(genericCallWithObjectTypeArgs2.ts, 5, 1))
function f2<T extends Base, U extends Base>(a: { x: T; y: U }) {
>f2 : Symbol(f2, Decl(genericCallWithObjectTypeArgs2.ts, 16, 49))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 19, 12))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
>U : Symbol(U, Decl(genericCallWithObjectTypeArgs2.ts, 19, 27))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
>a : Symbol(a, Decl(genericCallWithObjectTypeArgs2.ts, 19, 44))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 19, 48))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 19, 12))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 19, 54))
>U : Symbol(U, Decl(genericCallWithObjectTypeArgs2.ts, 19, 27))
return (x: T) => a.y;
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 20, 12))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 19, 12))
>a.y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 19, 54))
>a : Symbol(a, Decl(genericCallWithObjectTypeArgs2.ts, 19, 44))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 19, 54))
}
var r3 = f2({ x: new Derived(), y: new Derived2() }); // Derived => Derived2
>r3 : Symbol(r3, Decl(genericCallWithObjectTypeArgs2.ts, 23, 3))
>f2 : Symbol(f2, Decl(genericCallWithObjectTypeArgs2.ts, 16, 49))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgs2.ts, 23, 13))
>Derived : Symbol(Derived, Decl(genericCallWithObjectTypeArgs2.ts, 2, 1))
>y : Symbol(y, Decl(genericCallWithObjectTypeArgs2.ts, 23, 31))
>Derived2 : Symbol(Derived2, Decl(genericCallWithObjectTypeArgs2.ts, 5, 1))
interface I<T, U> {
>I : Symbol(I, Decl(genericCallWithObjectTypeArgs2.ts, 23, 53))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 25, 12))
>U : Symbol(U, Decl(genericCallWithObjectTypeArgs2.ts, 25, 14))
x: T;
>x : Symbol(I.x, Decl(genericCallWithObjectTypeArgs2.ts, 25, 19))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgs2.ts, 25, 12))
y: U;
>y : Symbol(I.y, Decl(genericCallWithObjectTypeArgs2.ts, 26, 9))
>U : Symbol(U, Decl(genericCallWithObjectTypeArgs2.ts, 25, 14))
}
var i: I<Base, Derived>;
>i : Symbol(i, Decl(genericCallWithObjectTypeArgs2.ts, 30, 3))
>I : Symbol(I, Decl(genericCallWithObjectTypeArgs2.ts, 23, 53))
>Base : Symbol(Base, Decl(genericCallWithObjectTypeArgs2.ts, 0, 0))
>Derived : Symbol(Derived, Decl(genericCallWithObjectTypeArgs2.ts, 2, 1))
var r4 = f2(i); // Base => Derived
>r4 : Symbol(r4, Decl(genericCallWithObjectTypeArgs2.ts, 31, 3))
>f2 : Symbol(f2, Decl(genericCallWithObjectTypeArgs2.ts, 16, 49))
>i : Symbol(i, Decl(genericCallWithObjectTypeArgs2.ts, 30, 3))
|