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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
=== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithObjectTypeArgsAndConstraints.ts ===
// Generic call with constraints infering type parameter from object member properties
// No errors expected
class C {
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
x: string;
>x : Symbol(C.x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 3, 9))
}
class D {
>D : Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
x: string;
>x : Symbol(D.x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 7, 9))
y: string;
>y : Symbol(D.y, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 8, 14))
}
class X<T> {
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 12, 8))
x: T;
>x : Symbol(X.x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 12, 12))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 12, 8))
}
module Class {
>Class : Symbol(Class, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 14, 1))
class G<T extends { x: string }> {
>G : Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 16, 14))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 12))
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 23))
foo<T extends { x: string }>(t: X<T>, t2: X<T>) {
>foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 23))
>t : Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 37))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
>t2 : Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 45))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
var x: T;
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 19, 15))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 18, 12))
return x;
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 19, 15))
}
}
var c1 = new X<C>();
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
var d1 = new X<D>();
>d1 : Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 25, 7))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>D : Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var g: G<{ x: string; y: string }>;
>g : Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 7))
>G : Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 16, 14))
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 14))
>y : Symbol(y, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 25))
var r = g.foo(c1, d1);
>r : Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 27, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 37, 7))
>g.foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>g : Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 7))
>foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>d1 : Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 25, 7))
var r2 = g.foo(c1, c1);
>r2 : Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 38, 7))
>g.foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>g : Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 26, 7))
>foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 17, 38))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
class G2<T extends C> {
>G2 : Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 27))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 13))
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
foo2<T extends C>(t: X<T>, t2: X<T>) {
>foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
>t : Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 26))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
>t2 : Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 34))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
var x: T;
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 32, 15))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 31, 13))
return x;
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 32, 15))
}
}
var g2: G2<D>;
>g2 : Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 36, 7))
>G2 : Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 27))
>D : Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var r = g2.foo2(c1, d1);
>r : Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 27, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 37, 7))
>g2.foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>g2 : Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 36, 7))
>foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>d1 : Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 25, 7))
var r2 = g2.foo2(c1, c1);
>r2 : Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 28, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 38, 7))
>g2.foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>g2 : Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 36, 7))
>foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 30, 27))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 24, 7))
}
module Interface {
>Interface : Symbol(Interface, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 39, 1))
interface G<T extends { x: string }> {
>G : Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 41, 18))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 16))
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 27))
foo<T extends { x: string }>(t: X<T>, t2: X<T>): T;
>foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 23))
>t : Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 37))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
>t2 : Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 45))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 43, 12))
}
var c1 = new X<C>();
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
var d1 = new X<D>();
>d1 : Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 47, 7))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>D : Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var g: G<{ x: string; y: string }>;
>g : Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 7))
>G : Symbol(G, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 41, 18))
>x : Symbol(x, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 14))
>y : Symbol(y, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 25))
var r = g.foo(c1, d1);
>r : Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 49, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 57, 7))
>g.foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>g : Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 7))
>foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>d1 : Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 47, 7))
var r2 = g.foo(c1, c1);
>r2 : Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 58, 7))
>g.foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>g : Symbol(g, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 48, 7))
>foo : Symbol(G.foo, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 42, 42))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
interface G2<T extends C> {
>G2 : Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 27))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 17))
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
foo2<T extends C>(t: X<T>, t2: X<T>): T;
>foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
>C : Symbol(C, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 0, 0))
>t : Symbol(t, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 26))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
>t2 : Symbol(t2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 34))
>X : Symbol(X, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
>T : Symbol(T, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 53, 13))
}
var g2: G2<D>;
>g2 : Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 56, 7))
>G2 : Symbol(G2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 27))
>D : Symbol(D, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 5, 1))
var r = g2.foo2(c1, d1);
>r : Symbol(r, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 49, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 57, 7))
>g2.foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>g2 : Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 56, 7))
>foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>d1 : Symbol(d1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 47, 7))
var r2 = g2.foo2(c1, c1);
>r2 : Symbol(r2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 50, 7), Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 58, 7))
>g2.foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>g2 : Symbol(g2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 56, 7))
>foo2 : Symbol(G2.foo2, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 52, 31))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
>c1 : Symbol(c1, Decl(genericClassWithObjectTypeArgsAndConstraints.ts, 46, 7))
}
|