-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
If I declare class using es6 class keyword:
class Foo {
constructor(foo, bar) {}
}
module.exports = Foo;And I try to load it using wire:
wire({
"foo": {
"module": "Foo",
"args": ["monty", "python"],
},
});I get an error:
TypeError: Class constructors cannot be invoked without 'new'
at BrowserConnectionFactory ()
at instantiate (.../node_modules/wire/lib/instantiate.js:37:20)
at createInstance (.../node_modules/wire/lib/plugin/basePlugin.js:250:7)
Wire (actually when) is trying to do Foo.apply(new_foo, args), which is not allowed in es6. Solution would be using new spread operator - new Foo(...args) , but that is not backwards-compatible.
PR #180 has possible workaround with named constructors which can be called with "apply".
Metadata
Metadata
Assignees
Labels
No labels