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

Constructor cannot be called as a function #1966

Closed
jruchaud opened this issue Jul 10, 2015 · 4 comments
Closed

Constructor cannot be called as a function #1966

jruchaud opened this issue Jul 10, 2015 · 4 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jruchaud
Copy link

I wrote this code to extends KeyboardEvent from native API:

class KeyEvent extends KeyboardEvent {
}

I use babel to transpile the code to ES5. But after, during executing the code, I get this error:

Uncaught TypeError: Failed to construct 'KeyboardEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.
@sebmck
Copy link
Contributor

sebmck commented Jul 10, 2015

Show the code you're using to create a KeyEvent please.

@jruchaud
Copy link
Author

It is just : new KeyEvent();

@sebmck
Copy link
Contributor

sebmck commented Jul 10, 2015

It'd be because the super class is being called with apply then. I don't think there's a way around this unless you just use native classes.

@jruchaud
Copy link
Author

What's pity.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 12, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
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

3 participants