-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for new.target #8494
Labels
Duplicate
An existing issue was already created
Comments
I think it should just be supported valid compile without getting into how to do a great emit. That said |
Revised: function Foo() {
var _newTarget = this === (typeof window === 'undefined' ? global : window) ? undefined : this && this.constructor;
console.log(_newTarget);
}
Foo(); When 'use strict';
function Foo() {
var _newTarget = this && this.constructor;
console.log(_newTarget);
}
Foo(); |
duplicate of #2551 |
Ooops... sorry... I will move over to there... |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TypeScript Version:
1.8.10
Code
Expected behavior:
When targeting ES6, this should compile without an error.
new.target
is an obscure bit of ES6, but it is there, for example running the code in an ES6 browser returns what is expected in thatnew.target === Foo
. When it is justFoo()
withoutnew
thennew.target === undefined
.While it maybe challenging to come up with an emit that works for ES5, it should be at least supported when targeting ES6.
I suspect and emit for ES6 might be something like this:
Actual behavior:
Compiles as:
The text was updated successfully, but these errors were encountered: