Skip to content
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

Subclassing Array #106

Closed
backspaces opened this issue Oct 29, 2014 · 1 comment
Closed

Subclassing Array #106

backspaces opened this issue Oct 29, 2014 · 1 comment
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@backspaces
Copy link

I realize subclassing Array in the past was a no-no, but it works perfectly well with CoffeeScript, and has been quite useful and performant.

Is there a way 6to5 could allow subclassing Array (and other built-ins?). NOT at the cost of the beautiful code generation .. but if its just that browser foo doesn't support, I'd be OK with that. And as I recall, es6 explicitly says we can subclass builtins.

@sebmck
Copy link
Contributor

sebmck commented Nov 3, 2014

This is more of a limitation on ES5 engines than 6to5. For example, the behaviour wouldn't be consistent or predictable across the different JavaScript engines, happy to be proven wrong however.

The following works on v8 but I'm not giving any guarantees that it'll work anywhere else:

class Foo extends Array {

}

var foo = new Foo;
foo.push("test");
foo; // { 0: "test", length: 1 }

@sebmck sebmck closed this as completed Nov 3, 2014
JacopKane pushed a commit to JacopKane/babel that referenced this issue Jan 11, 2018
…l#106)

* Slightly simplify logic

* Implement ES2016 check for simple parameter list in strict mode

See e.g. ECMA-262 7.0 14.1.2:

> It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
> IsSimpleParameterList of FormalParameters is false.

Similar clauses cover arrow functions, generator functions, methods, and
generator methods, as well as async functions and async arrow functions.
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

2 participants