Sometimes, we want to fix Error: *.default is not a constructor with TypeScript.
In this article, we’ll look at how to fix Error: *.default is not a constructor with TypeScript.
How to fix Error: *.default is not a constructor with TypeScript?
To fix Error: *.default is not a constructor with TypeScript, we should make sure we export a class as the default export.
For instance, we write
map_action_file.ts
export default class MapAction implements IMapAction {
//...
}
to export the MapAction
class in map_action_file.ts as a default export.
Then we import it by writing
import MapAction from "./map_action_file";
in another file in the same folder.
Conclusion
To fix Error: *.default is not a constructor with TypeScript, we should make sure we export a class as the default export.