How to fix the ‘Error: *.default is not a constructor’ error with TypeScript?

Sometimes, we want to fix the ‘Error: *.default is not a constructor’ error with TypeScript.

In this article, we’ll look at how to fix the ‘Error: *.default is not a constructor’ error with TypeScript.

How to fix the ‘Error: *.default is not a constructor’ error with TypeScript?

To fix the ‘Error: *.default is not a constructor’ error with TypeScript, we should make sure the default export we’re importing is a class or constructor.

For instance, we write

export default class MapAction implements IMapAction {
  //...
}

to export the MapAction class as a default export with export default .

Then we can import the class in another module by writing

import MapAction from "./map-action";

Conclusion

To fix the ‘Error: *.default is not a constructor’ error with TypeScript, we should make sure the default export we’re importing is a class or constructor.