You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError: Class constructor … cannot be invoked without 'new' is thrown when attempting to instantiate a class directly from module.__get__. However, if the class is first bound to a local variable, such as MyClass = module.__get__('MyClass'), the class can be instantiated.
Reproduction
hasclass.js
class Foo {
}
dorewire.js
const rewire = require('rewire');
const hasclass = rewire('./hasclass.js');
// No error when class if first bound to a local variable
const Foo = hasclass.__get__('Foo');
const foo1 = new Foo();
// Throws error if class is not bound to a local variable
const foo2 = new hasclass.__get__('Foo')();
Context:
Library version: 4.0.1
Environment: Windows
The text was updated successfully, but these errors were encountered:
Description
TypeError: Class constructor … cannot be invoked without 'new'
is thrown when attempting to instantiate a class directly frommodule.__get__
. However, if the class is first bound to a local variable, such asMyClass = module.__get__('MyClass')
, the class can be instantiated.Reproduction
hasclass.js
dorewire.js
Context:
The text was updated successfully, but these errors were encountered: