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
|
//// [tests/cases/conformance/classes/members/instanceAndStaticMembers/typeOfThisInInstanceMember2.ts] ////
=== typeOfThisInInstanceMember2.ts ===
class C<T> {
>C : C<T>
x = this;
>x : this
>this : this
foo() {
>foo : () => this
return this;
>this : this
}
constructor(x: T) {
>x : T
var t = this;
>t : this
>this : this
t.x;
>t.x : this
>t : this
>x : this
t.y;
>t.y : this
>t : this
>y : this
t.z;
>t.z : T
>t : this
>z : T
var r = t.foo();
>r : this
>t.foo() : this
>t.foo : () => this
>t : this
>foo : () => this
}
get y() {
>y : this
return this;
>this : this
}
z: T;
>z : T
}
var c: C<string>;
>c : C<string>
// all ok
var r = c.x;
>r : C<string>
>c.x : C<string>
>c : C<string>
>x : C<string>
var ra = c.x.x.x;
>ra : C<string>
>c.x.x.x : C<string>
>c.x.x : C<string>
>c.x : C<string>
>c : C<string>
>x : C<string>
>x : C<string>
>x : C<string>
var r2 = c.y;
>r2 : C<string>
>c.y : C<string>
>c : C<string>
>y : C<string>
var r3 = c.foo();
>r3 : C<string>
>c.foo() : C<string>
>c.foo : () => C<string>
>c : C<string>
>foo : () => C<string>
var r4 = c.z;
>r4 : string
>c.z : string
>c : C<string>
>z : string
var rs = [r, r2, r3];
>rs : C<string>[]
>[r, r2, r3] : C<string>[]
>r : C<string>
>r2 : C<string>
>r3 : C<string>
rs.forEach(x => {
>rs.forEach(x => { x.foo; x.x; x.y; x.z;}) : void
>rs.forEach : (callbackfn: (value: C<string>, index: number, array: C<string>[]) => void, thisArg?: any) => void
>rs : C<string>[]
>forEach : (callbackfn: (value: C<string>, index: number, array: C<string>[]) => void, thisArg?: any) => void
>x => { x.foo; x.x; x.y; x.z;} : (x: C<string>) => void
>x : C<string>
x.foo;
>x.foo : () => C<string>
>x : C<string>
>foo : () => C<string>
x.x;
>x.x : C<string>
>x : C<string>
>x : C<string>
x.y;
>x.y : C<string>
>x : C<string>
>y : C<string>
x.z;
>x.z : string
>x : C<string>
>z : string
});
|