Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Allow new.target in class properties #759

Merged
merged 1 commit into from
Oct 14, 2017
Merged

Allow new.target in class properties #759

merged 1 commit into from
Oct 14, 2017

Conversation

existentialism
Copy link
Member

Q A
Bug fix? yes
Breaking change? no
New feature? no
Deprecations? no
Spec compliancy? yes
Tests added/pass? yes
Fixed tickets Fixes #758
License MIT

@nicolo-ribaudo
Copy link
Member

Is new.target allowed in arrow parameters? e.g. class A { x = (p = new.target) => {} }

Also, I think class A { x = (new.target) } should throw.

@jridgewell
Copy link
Member

/cc @littledan, what's the expected behavior here?

@existentialism
Copy link
Member Author

Related: babel/babel#6243

@littledan
Copy link

littledan commented Oct 14, 2017

new.target would always be undefined in any of these cases, just like in a method.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved too early 😅
Can you add a test for the new.target can only be used in functions or class properties error message, so we get full coverage for this PR?

@littledan
Copy link

Would it make sense to add a test that verifies that, when you execute the code, you actually get undefined for new.target in these cases?

@nicolo-ribaudo
Copy link
Member

I think we should add them, but they must be in the Babel repository (after this PR is merged)

@existentialism existentialism changed the title Allow new.target in static field initializer Allow new.target in class properties Oct 14, 2017
@nicolo-ribaudo
Copy link
Member

LGTM

@hzoo
Copy link
Member

hzoo commented Oct 14, 2017

This will be better when babylon is merged into the monorepo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

static field initializer as an arrow function containing new.target is not allowed
5 participants