TypeError: Class constructor ResourceLoader cannot be invoked without 'new'
See original GitHub issueBasic info:
Cannot extend the ResourceLoader to create a custom ResourceLoader. This fails even using the example code from the README.md.
- Node.js version: v8.9.4 && v11.0.0
- jsdom version: v12 & v13
Minimal reproduction case
const jsdom = require('jsdom');
const { ResourceLoader } = jsdom;
class CustomResourceLoader extends ResourceLoader {
constructor() {
super({ strictSSL: false });
}
fetch(url, options) {
console.log('URL -- ', url, options);
return super.fetch(url, options);
}
}
const resources = new CustomResourceLoader();
How does similar code behave in browsers?
(Link to a jsbin or similar suggested.)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Javascript ES6 TypeError: Class constructor Client cannot be ...
When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invoked without 'new'.
Read more >Class constructor cannot be invoked without 'new' in TS
The "Class constructor cannot be invoked without new" error occurs when the target property in tsconfig.json is set to lower than es6 or...
Read more >Reactjs " Class constructor upload cannot be invoked without ...
Im trying to activate a function with reactjs But i keep getting the same error: Uncaught TypeError: Class constructor Upload cannot be ...
Read more >Angular + Webpack: Upgrade compiler target from es5
Uncaught Error : Class constructor SysceaElementDefault cannot be invoked without 'new': Error during instantiation of ScStorageRootService!.
Read more >Javascript ES6 TypeError Class constructor Client cannot be ...
When I try to execute nodemon command I always see this error TypeError: Class constructor Client cannot be invoked without 'new'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah OK. Sounds like a bug in TypeScript then, best filed on their repository.
Just put the easiest solution here as someone may encounter this. Just add
"target": "es6"
to yourtsconfig.json
.