js-ipfs
js-ipfs copied to clipboard
`IPFSService` is not assignable to the `MultiService` type parameter.
-
Version:
ipfsatv0.62.2ipfs-coreatv0.14.2ipfs-message-port-serveratv0.11.2tscatv4.6.3
-
Platform: The bug is with the TypeScript types, so the most relevant platform is
tscatv4.6.3 -
Subsystem:
ipfs-message-port-server
Severity: High. Type error prevents compilation with TypeScript.
Description:
When instantiating a Server with ipfs-message-port-server, the IPFSService is not assignable to the MultiService type parameter. I expect the a server can be instantiated with a service configured with an IPFS instance created by ipfs or ipfs-core.
Steps to reproduce the error:
In brief:
import { create } from "ipfs-core" // or "ipfs"
import { Server, IPFSService } from "ipfs-message-port-server"
const ipfs = await create()
const service = new IPFSService(ipfs)
const server = new Server(service)
Minimal reproduction: https://github.com/bgins/ipfs-message-port-server-type-error
Error message:
$ tsc
src/worker.ts:7:27 - error TS2345: Argument of type 'IPFSService' is not assignable to parameter of type
'MultiService<{ dag: { ipfs: ...; put: ...; get: ...; resolve: ...; }; core: { ipfs: ...; addAll: ...; add: ...;
cat: ...; ls: ...; }; files: { ipfs: ...; stat: ...; }; block: { ipfs: ...; get: ...; put: ...; rm: ...; stat: ...; }; }>'.
The types of 'dag.ipfs' are incompatible between these types.
Type 'IPFS<any>' is not assignable to type 'never'.
7 const server = new Server(service)
~~~~~~~
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:
- "Priority" labels will show how urgent this is for the team.
- "Status" labels will show if this is ready to be worked on, blocked, or in progress.
- "Need" labels will indicate if additional input or analysis is required.
Finally, remember to use https://discuss.ipfs.io if you just need general support.
@bgins: thanks for reporting. js-ipfs maintainers are tied up currently. Is this something you could potentially take on? Contributions welcome.
Hey @BigLep! Thanks for the reply. I'm also tied up at the moment, but I think it should be possible to work around this issue with a bit of type casting:
const service = new IPFSService(ipfs) as unknown as MultiService<IPFSService>
If that doesn't work out, I'll revisit.
js-IPFS is in the process of being deprecated, the replacement is Helia - please see the State of IPFS in JS post for a bit of background and the migration guide for how to port your app over.
There's no direct replacement for the message port server yet, but something similar should be fairly easy to create.