TypeScript: BUG: `allowSyntheticDefaultImports: true` breaks Typescript auto-import
- VSCode Version: 1.34.0
- OS Version: OS X 10.14.4
- Typescript Version: 3.4.5
- Create React App: 2.1.5
tsconfig.json:
{
"compilerOptions": {
"target": "es6",
"allowJs": true,
"skipLibCheck": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"lib": [
"esnext",
"dom"
]
},
"include": [
"src"
]
}
Behavior when true:

Behavior when false:

We have another project that seems to work fine with allowSyntheticDefaultImports: true. The other project is an Express app and its tsconfig.json is:
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"strict": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"sourceMap": true,
"declaration": true,
"outDir": "dist",
"resolveJsonModule": true,
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
},
"lib": [
"esnext",
"dom"
]
},
"include": [
"src/**/*"
]
}
We’ve directly copied its tsconfig.json, but that doesn’t seem to bring back auto-import.
Does this issue occur when all extensions are disabled?: Yes
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 15 (3 by maintainers)
I’m running into this same issue on my project with this
tsconfig.json:Commenting out
esModuleInteropandallowSyntheticDefaultImportsseems to fix it, but then I can’t do things like:As it expects:
And here is the output log for it: