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
|
=== 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.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
>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.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
constructor(public x: T) { }
>x : Symbol(C.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(C2.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(C4.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))
|