Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Basic] Import React "allowSyntheticDefaultImports" no longer valid #175

Closed
rpivo opened this issue Dec 30, 2019 · 4 comments
Closed

[Basic] Import React "allowSyntheticDefaultImports" no longer valid #175

rpivo opened this issue Dec 30, 2019 · 4 comments
Assignees
Labels
BASIC Basic Cheatsheet

Comments

@rpivo
Copy link

rpivo commented Dec 30, 2019

What cheatsheet is this about? (if applicable)

Basic cheatsheet

What's your issue or idea?

I think the paragraph in the doc about --allowSyntheticDefaultImportsvs esModuleInterop is no longer true. See the answers to this Stack Overflow question: https://stackoverflow.com/questions/52576203/do-i-ever-need-explicit-allowsyntheticdefaultimports-if-esmoduleinterop-is-true. Also see this now closed issue in the TypeScript GitHub discussing this: microsoft/TypeScript#26193.

@rpivo rpivo added the BASIC Basic Cheatsheet label Dec 30, 2019
@rpivo rpivo changed the title [Basic] Import React "allowSyntheticDefaultImports": true no longer true [Basic] Import React "allowSyntheticDefaultImports" no longer valid Dec 30, 2019
@swyxio
Copy link
Collaborator

swyxio commented Dec 30, 2019

thanks for the heads up! however i think in this case i dont think your sources are as accurate as mine is... (which is dan rosenwasser) - make sure to read his tweet. i don't see any of these comments being aware of this nuance.

@rpivo
Copy link
Author

rpivo commented Dec 30, 2019

Yeah, I almost decided to go with --allowSyntheticDefaultImports, but that Stack Overflow thread also linked to this TypeScript Github issue from August 2018, a little after the tweet from June 2018: microsoft/TypeScript#26193

In that thread, Daniel Rosenwasser and another TypeScript contributor discuss this, and it seems like the merged PR that came from the issue makes --allowSyntheticDefaultImports true whenever esModuleInterop is true.

It's also mentioned in the Compiler Options documentation under the esModuleInterop description: https://www.typescriptlang.org/docs/handbook/compiler-options.html

Emit __importStar and __importDefault helpers for runtime babel ecosystem compatibility and enable --allowSyntheticDefaultImports for typesystem compatibility.

(honestly, I need further clarification on these two -- just wondering how they work after the above mentioned PR, and based on what the docs say)

@orta
Copy link
Collaborator

orta commented Dec 31, 2019

I wrote fresh docs for them both here BTW: https://www.typescriptlang.org/v2/en/tsconfig#allowSyntheticDefaultImports

@rpivo
Copy link
Author

rpivo commented Dec 31, 2019

Thanks -- that cleared it up for me a lot.

@rpivo rpivo closed this as completed Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BASIC Basic Cheatsheet
Projects
None yet
Development

No branches or pull requests

3 participants