Typescript: Incorrect "Import may be converted to a default import" suggestion

Created on 6 Aug 2018  路  2Comments  路  Source: microsoft/TypeScript


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

Question Working as Intended

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.

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jbondc picture jbondc  路  3Comments

Zlatkovsky picture Zlatkovsky  路  3Comments

uber5001 picture uber5001  路  3Comments

blendsdk picture blendsdk  路  3Comments

MartynasZilinskas picture MartynasZilinskas  路  3Comments