TypeScript Version: 3.1.0-dev. 20180804
Search Terms: "Import may be converted to a default import"
Code
https://github.com/grantwwu/typescript-default-imports-test
Expected behavior:
Both test cases exit successfully.
Actual behavior:
npm run fail fails.
I am reporting this as an issue because VSCode is reporting that ts is suggesting that I convert the code in sinon-pass.ts to sinon-fail.ts, and provides a CodeFix for doing so. I'm not 100% sure, but it does seem like that's under this repo's purview, judging from https://github.com/Microsoft/TypeScript/blob/13bc46d9707036928e51be91d8d6aeaf95e63132/src/services/codefixes/useDefaultImport.ts
Playground Link: None; I don't know of any other packages which demonstrate this issue, and TS Playground doesn't seem to have sinon
Related Issues:
No
You set "allowSyntheticDefaultImports": true, in your tsconfig. That declares to the compiler that your module loader will support loading commonjs modules as default imports. If it doesn't, you should disable that option.
I don't know why I have that option; I copied the tsconfig.json in my code from my employer's internal repo.
I'll remove that option; we do not use any fancy module loaders. Thanks for the succint and clear explanation!
Most helpful comment
You set
"allowSyntheticDefaultImports": true,in your tsconfig. That declares to the compiler that your module loader will support loading commonjs modules as default imports. If it doesn't, you should disable that option.