core icon indicating copy to clipboard operation
core copied to clipboard

(runtime) global loadRemote doesn't support generic (ts fails)

Open crutch12 opened this issue 1 year ago • 2 comments

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

crutch12 avatar Apr 14 '24 17:04 crutch12

@zhoushaw tell me if you want me to provide PR with fix for this issue

crutch12 avatar Apr 15 '24 13:04 crutch12

If you know how to fix it and it will not mess with existing apis then contrib is welcome <3

ScriptedAlchemy avatar Apr 17 '24 00:04 ScriptedAlchemy