Issue
I changed tsconfig.json by adding this properties
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
in order to be able to import a npm package import * as ms from "ms";
But I still get this error
This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
What am I missing?
Update:
If I change with import ms from "ms"
, then it works fine with the compiler but not with VSCode linter and the error is
can only be default-imported using the 'allowSyntheticDefaultImports' flagts(1259)
index.d.ts(25, 1): This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
As I said now is working but VSCode have a problem.
Solution
The problem is how the package declared the export, you can still import using the default import:
import ms from "ms";
Answered By – Lucas Sousa
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0