2015-02-03 00:15:54 +01:00
|
|
|
//// [typeOfThisInInstanceMember.ts]
|
|
|
|
class C {
|
|
|
|
x = this;
|
|
|
|
foo() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
constructor(x: number) {
|
|
|
|
var t = this;
|
|
|
|
t.x;
|
|
|
|
t.y;
|
|
|
|
t.z;
|
|
|
|
var r = t.foo();
|
|
|
|
}
|
|
|
|
|
|
|
|
get y() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var c: C;
|
|
|
|
// all ok
|
|
|
|
var r = c.x;
|
|
|
|
var ra = c.x.x.x;
|
|
|
|
var r2 = c.y;
|
|
|
|
var r3 = c.foo();
|
|
|
|
var rs = [r, r2, r3];
|
|
|
|
|
|
|
|
rs.forEach(x => {
|
|
|
|
x.foo;
|
|
|
|
x.x;
|
|
|
|
x.y;
|
|
|
|
});
|
|
|
|
|
|
|
|
//// [typeOfThisInInstanceMember.js]
|
|
|
|
var C = (function () {
|
|
|
|
function C(x) {
|
|
|
|
this.x = this;
|
|
|
|
var t = this;
|
|
|
|
t.x;
|
|
|
|
t.y;
|
|
|
|
t.z;
|
|
|
|
var r = t.foo();
|
|
|
|
}
|
|
|
|
C.prototype.foo = function () {
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
Object.defineProperty(C.prototype, "y", {
|
|
|
|
get: function () {
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
return C;
|
|
|
|
})();
|
|
|
|
var c;
|
|
|
|
// all ok
|
|
|
|
var r = c.x;
|
|
|
|
var ra = c.x.x.x;
|
|
|
|
var r2 = c.y;
|
|
|
|
var r3 = c.foo();
|
2015-03-09 02:23:23 +01:00
|
|
|
var rs = [
|
|
|
|
r,
|
|
|
|
r2,
|
|
|
|
r3
|
|
|
|
];
|
2015-02-03 00:15:54 +01:00
|
|
|
rs.forEach(function (x) {
|
|
|
|
x.foo;
|
|
|
|
x.x;
|
|
|
|
x.y;
|
|
|
|
});
|