Default import for React in the library is forcing esModuleInterop flag to be set
See original GitHub issueHello, when importing the latest version of the library, during the build we get this error:
$ /Users/xx/work/yyyy/node_modules/.bin/tsc
../poject/node_modules/markdown-to-jsx/dist/index.d.ts:6:8 - error TS1259:
Module '"/Users/xx/work/project/node_modules/@types/react/index"' can only be default-imported using the 'esModuleInterop' flag
6 import React from 'react';
~~~~~
This is an issue for us, as its quite troublesome to enable this flag for our huge projet at this point.
Would it be possible to replace the import with import * as React from 'react'
, which would fix the problem and work everywhere? thank you
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Understanding esModuleInterop in tsconfig file - Stack Overflow
With flag esModuleInterop we can import CommonJS modules in compliance ... a default property on the exports object in the moment library.
Read more >Module can only be default-imported using esModuleInterop flag
The error "Module can only be default-imported using esModuleInterop flag" occurs when we try to import a CommonJS module into an ES6 module....
Read more >esModuleInterop is (should not be) required #1977 - GitHub
Enabling it requires that all other imports where there is no default export to be updated too ( import * as x vs...
Read more >TSConfig Option: esModuleInterop - TypeScript
a default import like import moment from "moment" acts the same as const moment = require("moment").default. This mis-match causes these two issues: the...
Read more >Troubleshooting Handbook: tsconfig.json
Selected flags and why we like them: esModuleInterop : disables namespace imports ( import * as foo from "foo" ) and enables CJS/AMD/UMD...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nice, it works! Thank you very much for your help!
If someone else comes across this problem, this is what I added to the
jest.config.js
:@feedm3 you could probably fix this by using
moduleNameMapper
in jest config and forcing it to use the ESM bundle