116 lines
5.7 KiB
Plaintext
116 lines
5.7 KiB
Plaintext
=== 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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
|
|
f() {
|
|
>f : Symbol(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.d.ts, 660, 26))
|
|
|
|
return a + x.getDate();
|
|
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 6, 11))
|
|
>x.getDate : Symbol(Date.getDate, Decl(lib.d.ts, 660, 26))
|
|
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 5, 11))
|
|
>getDate : Symbol(Date.getDate, Decl(lib.d.ts, 660, 26))
|
|
}
|
|
}
|
|
|
|
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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
|
|
foo: T;
|
|
>foo : Symbol(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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
|
|
var r2 = i.foo.getDate();
|
|
>r2 : Symbol(r2, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 17, 3))
|
|
>i.foo.getDate : Symbol(Date.getDate, Decl(lib.d.ts, 660, 26))
|
|
>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.d.ts, 660, 26))
|
|
|
|
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.d.ts, 660, 26))
|
|
|
|
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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>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.d.ts, 660, 26))
|
|
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 20, 3))
|
|
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>getDate : Symbol(Date.getDate, Decl(lib.d.ts, 660, 26))
|
|
|
|
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.d.ts, 660, 26))
|
|
|
|
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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
>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.d.ts, 660, 26))
|
|
|
|
return a + x.getDate();
|
|
>a : Symbol(a, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 28, 11))
|
|
>x.getDate : Symbol(Date.getDate, Decl(lib.d.ts, 660, 26))
|
|
>x : Symbol(x, Decl(propertyAccessOnTypeParameterWithConstraints.ts, 27, 26))
|
|
>getDate : Symbol(Date.getDate, Decl(lib.d.ts, 660, 26))
|
|
}
|
|
}
|
|
|
|
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.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
|
|
|