27 lines
486 B
TypeScript
27 lines
486 B
TypeScript
//// [badThisBinding.ts]
|
|
declare function foo(a:any): any;
|
|
declare function bar(a:any): any;
|
|
|
|
class Greeter {
|
|
constructor() {
|
|
foo(() => {
|
|
bar(() => {
|
|
var x = this;
|
|
});
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
//// [badThisBinding.js]
|
|
var Greeter = (function () {
|
|
function Greeter() {
|
|
var _this = this;
|
|
foo(function () {
|
|
bar(function () {
|
|
var x = _this;
|
|
});
|
|
});
|
|
}
|
|
return Greeter;
|
|
}());
|