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
|
=== tests/cases/conformance/types/typeParameters/typeParameterLists/propertyAccessOnTypeParameterWithConstraints.ts ===
// generic types should behave as if they have properties of their constraint type
// no errors expected
class C<T extends Date> {
>C : Symbol(C, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 0, 0))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 3, 8))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
f() {
>f : Symbol(C.f, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 3, 25))
var x: T;
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 5, 11))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 3, 8))
var a = x['getDate'](); // number
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 6, 11))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 5, 11))
>'getDate' : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
return a + x.getDate();
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 6, 11))
>x.getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 5, 11))
>getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
}
}
var r = (new C<Date>()).f();
>r : Symbol(r, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 11, 3))
>(new C<Date>()).f : Symbol(C.f, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 3, 25))
>C : Symbol(C, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 0, 0))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
>f : Symbol(C.f, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 3, 25))
interface I<T extends Date> {
>I : Symbol(I, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 11, 28))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 12))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
foo: T;
>foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 29))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 12))
}
var i: I<Date>;
>i : Symbol(i, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 16, 3))
>I : Symbol(I, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 11, 28))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
var r2 = i.foo.getDate();
>r2 : Symbol(r2, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 17, 3))
>i.foo.getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
>i.foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 29))
>i : Symbol(i, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 16, 3))
>foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 29))
>getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
var r2b = i.foo['getDate']();
>r2b : Symbol(r2b, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 18, 3))
>i.foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 29))
>i : Symbol(i, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 16, 3))
>foo : Symbol(I.foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 13, 29))
>'getDate' : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
var a: {
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 20, 3))
<T extends Date>(): T;
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 21, 5))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 21, 5))
}
var r3 = a<Date>().getDate();
>r3 : Symbol(r3, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 23, 3))
>a<Date>().getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 20, 3))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
>getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
var r3b = a()['getDate']();
>r3b : Symbol(r3b, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 24, 3))
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 20, 3))
>'getDate' : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
var b = {
>b : Symbol(b, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 26, 3))
foo: <T extends Date>(x: T) => {
>foo : Symbol(foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 26, 9))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 27, 10))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 27, 26))
>T : Symbol(T, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 27, 10))
var a = x['getDate'](); // number
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 28, 11))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 27, 26))
>'getDate' : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
return a + x.getDate();
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 28, 11))
>x.getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 27, 26))
>getDate : Symbol(Date.getDate, Decl(lib.es5.d.ts, --, --))
}
}
var r4 = b.foo(new Date());
>r4 : Symbol(r4, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 33, 3))
>b.foo : Symbol(foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 26, 9))
>b : Symbol(b, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 26, 3))
>foo : Symbol(foo, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 26, 9))
>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --))
|