question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Class constructor ResourceLoader cannot be invoked without 'new'

See original GitHub issue

Basic 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
domeniccommented, Dec 18, 2018

Ah OK. Sounds like a bug in TypeScript then, best filed on their repository.

0reactions
gogooutcommented, May 24, 2019

Just put the easiest solution here as someone may encounter this. Just add "target": "es6" to your tsconfig.json.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found