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 doesn't work #3181

Closed
kasperpeulen opened this issue Sep 24, 2017 · 8 comments
Closed

Subclassing Array doesn't work #3181

kasperpeulen opened this issue Sep 24, 2017 · 8 comments

Comments

@kasperpeulen
Copy link
Contributor

kasperpeulen commented Sep 24, 2017

I have the following code:

export default class Days extends Array {
  today() {
    return this.find(day => day.startedAt.isSame(moment(), 'day'));
  }
}

This code works if I just copy paste it to the chrome console, but not in create react app:

image

Anyway to get this to somehow transpile correctly? I tried importing babel-polyfill.

Also, is it possible to somehow tell create-react-app that I don't need to support IE11? Because I think that otherwise, this could work natively, and I wouldn't need a polyfill.

@kasperpeulen
Copy link
Contributor Author

Ah there is an PR for that:
#2358

can we have that in :D

@miraage
Copy link

miraage commented Oct 3, 2017

Anyway to get this to somehow transpile correctly?
Also, is it possible to somehow tell create-react-app that I don't need to support IE11?

Yes.

  • npm run eject
  • configure by yourself

@kasperpeulen
Copy link
Contributor Author

I think using browerslist in package.json is a lot better, like babel-preste-env does it

@miraage
Copy link

miraage commented Oct 3, 2017

@kasperpeulen agree. But if you need it ASAP - you got the plan.

@gaearon
Copy link
Contributor

gaearon commented Nov 3, 2017

Yeah, it won't work until we allow targeting just modern browsers.

@gaearon gaearon closed this as completed Nov 3, 2017
@kasperpeulen
Copy link
Contributor Author

@gaearon would you take a PR that allows to set the babel-env browser option using the package.json browserlist field?

@kasperpeulen
Copy link
Contributor Author

relates to: #892

@gaearon
Copy link
Contributor

gaearon commented Nov 3, 2017

That's the plan.

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants