Skip to content

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

@crutch12

Description

@crutch12

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

Metadata

Metadata

Assignees

Labels

🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions