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

Sometimes, we want to fix JavaScript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’.

In this article, we’ll look at how to fix JavaScript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’.

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

To fix JavaScript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’, we need to transpile our code to ES6 or later.

In tsconfig.json, we write

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

to set the target to 'ES6' to transpile the code to ES6 so ES6 classes are kept after transpiling.

Conclusion

To fix JavaScript ES6 TypeError: Class constructor Client cannot be invoked without ‘new’, we need to transpile our code to ES6 or later.