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.
Advertisement
Answer
The problem is how the package declared the export, you can still import using the default import:
import ms from "ms";