139 lines
5.6 KiB
Plaintext
139 lines
5.6 KiB
Plaintext
=== tests/cases/conformance/types/typeParameters/typeArgumentLists/constraintSatisfactionWithAny.ts ===
|
|
// any is not a valid type argument unless there is no constraint, or the constraint is any
|
|
|
|
function foo<T extends String>(x: T): T { return null; }
|
|
>foo : Symbol(foo, Decl(constraintSatisfactionWithAny.ts, 0, 0))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 2, 13))
|
|
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 2, 31))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 2, 13))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 2, 13))
|
|
|
|
function foo2<T extends { x: number }>(x: T): T { return null; }
|
|
>foo2 : Symbol(foo2, Decl(constraintSatisfactionWithAny.ts, 2, 56))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 3, 14))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 3, 25))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 3, 39))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 3, 14))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 3, 14))
|
|
|
|
//function foo3<T extends T[]>(x: T): T { return null; }
|
|
function foo4<T extends <T>(x: T) => void>(x: T): T { return null; }
|
|
>foo4 : Symbol(foo4, Decl(constraintSatisfactionWithAny.ts, 3, 64))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 5, 14))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 5, 25))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 5, 28))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 5, 25))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 5, 43))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 5, 14))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 5, 14))
|
|
|
|
var a;
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
foo(a);
|
|
>foo : Symbol(foo, Decl(constraintSatisfactionWithAny.ts, 0, 0))
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
foo2(a);
|
|
>foo2 : Symbol(foo2, Decl(constraintSatisfactionWithAny.ts, 2, 56))
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
//foo3(a);
|
|
foo4(a);
|
|
>foo4 : Symbol(foo4, Decl(constraintSatisfactionWithAny.ts, 3, 64))
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
var b: number;
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
foo<any>(b);
|
|
>foo : Symbol(foo, Decl(constraintSatisfactionWithAny.ts, 0, 0))
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
foo2<any>(b);
|
|
>foo2 : Symbol(foo2, Decl(constraintSatisfactionWithAny.ts, 2, 56))
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
//foo3<any>(b);
|
|
foo4<any>(b);
|
|
>foo4 : Symbol(foo4, Decl(constraintSatisfactionWithAny.ts, 3, 64))
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
//function foo5<T extends String, U extends T>(x: T, y: U): T { return null; }
|
|
//foo5(a, a);
|
|
//foo5<any, any>(b, b);
|
|
|
|
class C<T extends String> {
|
|
>C : Symbol(C, Decl(constraintSatisfactionWithAny.ts, 16, 13))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 22, 8))
|
|
>String : Symbol(String, Decl(lib.d.ts, 275, 1), Decl(lib.d.ts, 443, 11))
|
|
|
|
constructor(public x: T) { }
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 23, 16))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 22, 8))
|
|
}
|
|
|
|
var c1 = new C(a);
|
|
>c1 : Symbol(c1, Decl(constraintSatisfactionWithAny.ts, 26, 3))
|
|
>C : Symbol(C, Decl(constraintSatisfactionWithAny.ts, 16, 13))
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
var c2 = new C<any>(b);
|
|
>c2 : Symbol(c2, Decl(constraintSatisfactionWithAny.ts, 27, 3))
|
|
>C : Symbol(C, Decl(constraintSatisfactionWithAny.ts, 16, 13))
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
class C2<T extends { x: number }> {
|
|
>C2 : Symbol(C2, Decl(constraintSatisfactionWithAny.ts, 27, 23))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 29, 9))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 29, 20))
|
|
|
|
constructor(public x: T) { }
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 30, 16))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 29, 9))
|
|
}
|
|
|
|
var c3 = new C2(a);
|
|
>c3 : Symbol(c3, Decl(constraintSatisfactionWithAny.ts, 33, 3))
|
|
>C2 : Symbol(C2, Decl(constraintSatisfactionWithAny.ts, 27, 23))
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
var c4 = new C2<any>(b);
|
|
>c4 : Symbol(c4, Decl(constraintSatisfactionWithAny.ts, 34, 3))
|
|
>C2 : Symbol(C2, Decl(constraintSatisfactionWithAny.ts, 27, 23))
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
//class C3<T extends T[]> {
|
|
// constructor(public x: T) { }
|
|
//}
|
|
|
|
//var c5 = new C3(a);
|
|
//var c6 = new C3<any>(b);
|
|
|
|
class C4<T extends <T>(x:T) => T> {
|
|
>C4 : Symbol(C4, Decl(constraintSatisfactionWithAny.ts, 34, 24))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 43, 9))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 43, 20))
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 43, 23))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 43, 20))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 43, 20))
|
|
|
|
constructor(public x: T) { }
|
|
>x : Symbol(x, Decl(constraintSatisfactionWithAny.ts, 44, 16))
|
|
>T : Symbol(T, Decl(constraintSatisfactionWithAny.ts, 43, 9))
|
|
}
|
|
|
|
var c7 = new C4(a);
|
|
>c7 : Symbol(c7, Decl(constraintSatisfactionWithAny.ts, 47, 3))
|
|
>C4 : Symbol(C4, Decl(constraintSatisfactionWithAny.ts, 34, 24))
|
|
>a : Symbol(a, Decl(constraintSatisfactionWithAny.ts, 6, 3))
|
|
|
|
var c8 = new C4<any>(b);
|
|
>c8 : Symbol(c8, Decl(constraintSatisfactionWithAny.ts, 48, 3))
|
|
>C4 : Symbol(C4, Decl(constraintSatisfactionWithAny.ts, 34, 24))
|
|
>b : Symbol(b, Decl(constraintSatisfactionWithAny.ts, 12, 3))
|
|
|
|
|
|
|