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

ECMAScript 2015 Classes with td.constructor() #240

Closed
sgtoj opened this issue May 4, 2017 · 2 comments
Closed

ECMAScript 2015 Classes with td.constructor() #240

sgtoj opened this issue May 4, 2017 · 2 comments

Comments

@sgtoj
Copy link
Contributor

sgtoj commented May 4, 2017

ECMAScript 2015 class supported?

function Dog() {}
const DogFake = td.constructor(Dog);
const dog = new DogFake();

The above works; with Dog is defined as a function. The following does not work.

class Dog {
    constructor() { }
    bark() { return "bark! bark!"; }
}

const DogFake = td.constructor(Dog);
const dog = new DogFake(); // TypeError: Class constructor cannot be invoked without 'new'
@searls
Copy link
Member

searls commented May 4, 2017

Yes, supported, but if you aren't transpiling, then you are going to hit #157 (edit: got the number wrong at first)

@searls
Copy link
Member

searls commented May 5, 2017

Had a second look, definitely a dupe. Closing.

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

No branches or pull requests

2 participants