Closed JonasDoe closed 2 weeks ago
esModuleInterop
depends on the __esModule
property in order to work, but Node's --experimental-require-module
doesn't generate that. See https://github.com/nodejs/node/issues/52697
Also https://github.com/nodejs/node/pull/52166
Once that experimental feature lands (unexperimentally) in Node, you'll need to a) update to a version of TypeScript, which will eventually exist, that supports it and b) set module: nodenext
in tsconfig
I see! Thank you for the reponse!
🔎 Search Terms
"cjs esm esModuleInterop default", "common esm esModuleInterop default"
🕗 Version & Regression Information
⏯ Playground Link
https://github.com/JonasDoe/typescript-esm-issue
💻 Code
With
esModuleInterop=true
:The transpiled code will be:
🙁 Actual behavior
--experimental-require-module
is supported.esModuleInterop
{"default": {"default": the-imported-object}}
, sothe-imported-object
isn't found🙂 Expected behavior
{"default": the-imported-object}
, so without the double nesting.Additional information about the issue
The original suggestion that this is a bug in TypeScript came from here: https://github.com/panva/node-oidc-provider/discussions/1249#discussioncomment-9241520, and by a person with greater knowledge about Node and TypeScript. So I'm sorry if I left something unclear.