-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
TS 4.7.1-rc cannot resolve default
CJS or ESM exports with module nodenext
.
#49189
Comments
Possibly related to #48845 |
The issue is that the typings describe an ES module with a default export (which actually exists at |
Thanks @andrewbranch. Similar to what you mentioned here, I think the community will need to open PRs with these individual libraries to update their types. |
To those that run into this issue, I'd like to give a shoutout to In the interim @JacobLey who published default-import as an interim workaround as described here. |
On my side, I hacked my way by redefining the import explicitly: import _useSWR, { SWRHook } from 'swr';
const useSWR = _useSWR as unknown as SWRHook |
Bug Report
In React development the NPM packages classnames and clsx, are extremely popular, but TS 4.7.1-rc cannot resolve their default export:
Results in the error(s):
Looking at the
package.json
files for both theclsx
andclassnames
packages, they each specify thetypes
property.clsx/package.json
clsx/clsx.d.ts
classnames/package.json
classnames/index.d.ts
🔎 Search Terms
nodenext
,node16
,default export
,expression is not callable
🕗 Version & Regression Information
Exists in TS
4.7.0-beta
,4.7.1-rc
and4.8.0-dev.20220520
.nodenext
is a new feature.⏯ Playground Link
Playground link - N/A requires external dependencies.
Sample repo - https://github.com/scott-lc/tsc-issue-220520
💻 Code
tsconfig.json
Also see this repo.
🙁 Actual behavior
Code fails to compile with
module: nodenext
. Works fine pre 4.7 withmodule: esnext
.🙂 Expected behavior
nodenext
module resolution to not require changes to popular third-party NPM code.The text was updated successfully, but these errors were encountered: