Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript Error: Both MemoryBlockstore & MemoryDatastore have mismatched types when being passed to createHelia()` #54

Open
AustinFoss opened this issue May 2, 2023 · 1 comment

Comments

@AustinFoss
Copy link

When attempting to integrate the 301.js example from the Helia 101 example repo with a Nuxt3 project I ran into problems using Helia in a TypeScript context.

Lines 50 & 51 in the return statement of createHelia both datastore & blockstore are throwing similar but different errors.

creatHelia(init?: HeliaInit | undefined) is expecting the "Datastore" & "BlockStore" elements of the HeliaInit interface to have matching interfaces to the ones imported from interface-datastore & interface-blockstore

However in the 301 example the two value assigned to those elements are imported from datastore-core & blockstore-core as MemoryDatastore & MemoryBlockstore respectively.

Datastore error:

Type 'MemoryDatastore' is not assignable to type 'Datastore<{}, {}, {}, {}, {}, {}, {}, {}, {}, {}>'.
The types of 'batch().put' are incompatible between these types.

Blockstore error:

Property 'getAll' is missing in type 'MemoryBlockstore' but required in type 'Blockstore<{}, {}, {}, {}, {}, {}, {}, {}>'.

I'm aware that Nuxt3 is not currently among the existing examples, and non of the existing ones show Typescript compatibility so I'll probably pause my experiment here for now.

Hopefully this provides enough documentation about the problem for yourselves to replicate the issue.

@AustinFoss
Copy link
Author

I've gone ahead and implemented a quick work around for myself that fixes the Typescript problem, still can't get Nuxt3 working as it complains about something else (I think it's vite related because the error mentions os.networkinterfaces so something to do with bundling maybe).

ipfs/helia@main...AustinFoss:helia:heliainit-interface-fix

I haven't created a pull request or anything for it yet because this feels hacky but hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant