Categories
JavaScript Answers

How to fix JavaScript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’?

Spread the love

To fix JavaScript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’, we should set the build target to a recent version of JavaScript.

For instance, we write

{
  //...
  "compilerOptions": {
    "target": "ES2017"
  }
}

in tsconfig.json to set the TypeScript compiler build target to ES2017 to avoid transpilation of ES6 classes to ES5 constructor functions that cause this error.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *