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
|
=== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithObjectTypeArgsAndConstraints.ts ===
// Generic call with constraints infering type parameter from object member properties
// No errors expected
class C {
>C : Symbol(C, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 0, 0))
x: string;
>x : Symbol(C.x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 3, 9))
}
class D {
>D : Symbol(D, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 5, 1))
x: string;
>x : Symbol(D.x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 7, 9))
y: string;
>y : Symbol(D.y, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 8, 14))
}
class X<T> {
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 12, 8))
x: T;
>x : Symbol(X.x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 12, 12))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 12, 8))
}
function foo<T extends { x: string }>(t: X<T>, t2: X<T>) {
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 14, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 24))
>t : Symbol(t, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 38))
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
>t2 : Symbol(t2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 46))
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
var x: T;
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 17, 7))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
return x;
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 17, 7))
}
var c1 = new X<C>();
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>C : Symbol(C, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 0, 0))
var d1 = new X<D>();
>d1 : Symbol(d1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 22, 3))
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>D : Symbol(D, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 5, 1))
var r = foo(c1, d1);
>r : Symbol(r, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 23, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 31, 3))
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 14, 1))
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>d1 : Symbol(d1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 22, 3))
var r2 = foo(c1, c1);
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 32, 3))
>foo : Symbol(foo, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 14, 1))
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
function foo2<T extends C>(t: X<T>, t2: X<T>) {
>foo2 : Symbol(foo2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 21))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
>C : Symbol(C, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 0, 0))
>t : Symbol(t, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 27))
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
>t2 : Symbol(t2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 35))
>X : Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
var x: T;
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 27, 7))
>T : Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
return x;
>x : Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 27, 7))
}
var r = foo2(c1, d1);
>r : Symbol(r, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 23, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 31, 3))
>foo2 : Symbol(foo2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 21))
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>d1 : Symbol(d1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 22, 3))
var r2 = foo2(c1, c1);
>r2 : Symbol(r2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 32, 3))
>foo2 : Symbol(foo2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 21))
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>c1 : Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
|