-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScriptThe issue relates to the emission of JavaScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
π Search Terms
ES5, this alias
π Version & Regression Information
- This changed between versions 5.1.6 and 5.2.2
β― Playground Link
π» Code
// @target: es5
// @showEmit: true
abstract class Foo {
constructor(shouldThrow: boolean) {
if (shouldThrow) {
throw new Error('Please retry');
} else {
console.log('OK');
}
}
}
class Bar extends Foo {
constructor() {
try {
super(true);
} catch (e: unknown) {
console.log('Error: ' + (e as Error).message);
// retry
super(false);
}
}
}
new Bar();Target: ES5
π Actual behavior
_this is not defined
π Expected behavior
No error
Additional information about the issue
In TS5.2.2 output var _this = this; has been removed, but _this is still being used.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: JS EmitThe issue relates to the emission of JavaScriptThe issue relates to the emission of JavaScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue