core
core copied to clipboard
(runtime) global loadRemote doesn't support generic (ts fails)
Describe the bug
This example fails:
import { loadRemote, init } from '@module-federation/enhanced/runtime';
// init(...)
loadRemote<{add: (...args: Array<number>)=> number }>("app2/util").then((md)=>{
md.add(1,2,3);
});
With error TS2558: Expected 0 type arguments, but got 1
Because global loadRemote implementation doesn't support generics:
https://github.com/module-federation/universe/blob/920d9869836dfe477e0139673ca3714248fb8827/packages/runtime/src/index.ts#L40
Reproduction
https://stackblitz.com/edit/vitejs-vite-ol6j9b?file=src%2Fmain.ts
Used Package Manager
npm
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 8.15.3 - /usr/local/bin/pnpm
Validations
- [X] Read the docs.
- [X] Read the common issues list.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Module federation issue and not a framework-specific issue.
- [X] The provided reproduction is a minimal reproducible example of the bug.
@zhoushaw tell me if you want me to provide PR with fix for this issue
If you know how to fix it and it will not mess with existing apis then contrib is welcome <3