TypeScript/tests/baselines/reference/genericCallWithObjectTypeArgsAndConstraints.types
2015-04-13 14:29:37 -07:00

109 lines
5.7 KiB
Plaintext

=== 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 : C, Symbol(C, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 0, 0))
x: string;
>x : string, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 3, 9))
}
class D {
>D : D, Symbol(D, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 5, 1))
x: string;
>x : string, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 7, 9))
y: string;
>y : string, Symbol(y, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 8, 14))
}
class X<T> {
>X : X<T>, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 12, 8))
x: T;
>x : T, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 12, 12))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 12, 8))
}
function foo<T extends { x: string }>(t: X<T>, t2: X<T>) {
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(foo, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 14, 1))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
>x : string, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 24))
>t : X<T>, Symbol(t, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 38))
>X : X<T>, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
>t2 : X<T>, Symbol(t2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 46))
>X : X<T>, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
var x: T;
>x : T, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 17, 7))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 16, 13))
return x;
>x : T, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 17, 7))
}
var c1 = new X<C>();
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>new X<C>() : X<C>
>X : typeof X, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>C : C, Symbol(C, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 0, 0))
var d1 = new X<D>();
>d1 : X<D>, Symbol(d1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 22, 3))
>new X<D>() : X<D>
>X : typeof X, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>D : D, Symbol(D, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 5, 1))
var r = foo(c1, d1);
>r : C, Symbol(r, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 23, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 31, 3))
>foo(c1, d1) : C
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(foo, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 14, 1))
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>d1 : X<D>, Symbol(d1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 22, 3))
var r2 = foo(c1, c1);
>r2 : C, Symbol(r2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 32, 3))
>foo(c1, c1) : C
>foo : <T extends { x: string; }>(t: X<T>, t2: X<T>) => T, Symbol(foo, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 14, 1))
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
function foo2<T extends C>(t: X<T>, t2: X<T>) {
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(foo2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 21))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
>C : C, Symbol(C, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 0, 0))
>t : X<T>, Symbol(t, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 27))
>X : X<T>, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
>t2 : X<T>, Symbol(t2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 35))
>X : X<T>, Symbol(X, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 10, 1))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
var x: T;
>x : T, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 27, 7))
>T : T, Symbol(T, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 26, 14))
return x;
>x : T, Symbol(x, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 27, 7))
}
var r = foo2(c1, d1);
>r : C, Symbol(r, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 23, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 31, 3))
>foo2(c1, d1) : C
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(foo2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 21))
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>d1 : X<D>, Symbol(d1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 22, 3))
var r2 = foo2(c1, c1);
>r2 : C, Symbol(r2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 3), Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 32, 3))
>foo2(c1, c1) : C
>foo2 : <T extends C>(t: X<T>, t2: X<T>) => T, Symbol(foo2, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 24, 21))
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))
>c1 : X<C>, Symbol(c1, Decl(genericCallWithObjectTypeArgsAndConstraints.ts, 21, 3))