Open
Description
🐛 Bug Report
When using typescript with {"module": "NodeNext","moduleResolution": "nodenext",}
, the module @types/loadable__component
exports {default:loadableFunc}
when it should export loadableFunc
.
To Reproduce
With this typescript config:
{
"compilerOptions": {
"baseUrl": ".",
"module": "NodeNext",
"moduleResolution": "nodenext",
"jsx": "preserve",
"allowSyntheticDefaultImports": false,
"noEmit": true,
"isolatedModules": true,
"strict": true,
"allowUmdGlobalAccess": true,
"esModuleInterop": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,
"allowImportingTsExtensions": true
},
"include": [
"./*.ts"
],
}
And this code:
import loadable from "@loadable/component";
loadable(() => import("./component.ts"));
Typescript will print this error:
test.ts:4:1 - error TS2349: This expression is not callable.
Type 'typeof import("/Users/simonparis/temp/node_modules/@types/loadable__component/index")' has no call signatures.
4 loadable(() => import("./component.ts"));
~~~~~~~~
I don't fully understand this behavior, but setting type:module
in the package.json file of the types package seems to fix it. Unsure if that would break anything. The types package may need both a CJS and ESM copy.
Expected behavior
This should not be an error.
Link to repl or repo (highly encouraged)
https://github.com/simon-paris/loadable-types-bug-repro
Issues without a reproduction link are likely to stall.
Run npx envinfo --system --binaries --npmPackages @loadable/component,@loadable/server,@loadable/webpack-plugin,@loadable/babel-plugin --markdown --clipboard
Paste the results here:
## System:
- OS: macOS 13.5
- CPU: (8) arm64 Apple M1 Pro
- Memory: 113.53 MB / 16.00 GB
- Shell: 5.9 - /bin/zsh
## Binaries:
- Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
- npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
- pnpm: 9.11.0 - ~/.nvm/versions/node/v22.12.0/bin/pnpm
- bun: 1.0.0 - ~/.bun/bin/bun
- Watchman: 2024.11.18.00 - /opt/homebrew/bin/watchman
## npmPackages:
- @loadable/component: ^5.16.4 => 5.16.4
Metadata
Metadata
Assignees
Labels
No labels