Skip to content

Instantly share code, notes, and snippets.

@ShinNoNoir
Created October 6, 2012 10:15
Show Gist options
  • Save ShinNoNoir/3844548 to your computer and use it in GitHub Desktop.
Save ShinNoNoir/3844548 to your computer and use it in GitHub Desktop.
/*
Bug:
TypeScript compiler should generate a *fresh* variable name for a lexically captured this pointer.
For example, in the lambda assigned to window.onmousemove shown below, the captured outer this-pointer
should not be named "_this" since it would clash with an existing local variable, but instead should
be given a name that is not in scope, e.g. "_this2".
Tested in:
http://www.typescriptlang.org/Playground/
*/
class Tracker {
count = 0;
start() {
var _this = 0;
window.onmousemove = e => {
this.count++;
console.log(this.count * _this);
}
}
}
var t = new Tracker();
t.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment