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

Typing doesn't work with npm:@deno/kv #185

Open
RuiNtD opened this issue Mar 1, 2024 · 4 comments
Open

Typing doesn't work with npm:@deno/kv #185

RuiNtD opened this issue Mar 1, 2024 · 4 comments

Comments

@RuiNtD
Copy link

RuiNtD commented Mar 1, 2024

Okay, so if you use npm:@deno/kv in Deno, the NPM package is set up to redirect to Deno.kv if it is defined, making it viable to use npm:@dneo/kv in Deno. However, when I pass a Kv instance from npm:@deno/kv into kvdex in Deno, I get a type error:

> deno check src/lib/db.ts
Check file:///.../src/lib/db.ts
error: TS2345 [ERROR]: Argument of type 'import("file:///.../node_modules/.deno/@[email protected]/node_modules/@deno/kv/esm/kv_types.d.ts").Kv' is not assignable to parameter of type 'Deno.Kv'.
  Property 'commitVersionstamp' is missing in type 'import("file:///.../node_modules/.deno/@[email protected]/node_modules/@deno/kv/esm/kv_types.d.ts").Kv' but required in type 'Deno.Kv'.
export const db = kvdex(kv, {
                        ~~
    at file:///.../src/lib/db.ts:28:25

    'commitVersionstamp' is declared here.
        commitVersionstamp(): symbol;
        ~~~~~~~~~~~~~~~~~~
        at asset:///lib.deno.unstable.d.ts:1940:5

I assume this is simply because the NPM package is more of a stable release than Deno.kv. A possible solution is to just change all instances of the Deno.Kv type to { Kv } from "npm:@deno/kv"

@RuiNtD RuiNtD changed the title Typing doesn't support npm:@deno/kv in Deno. Typing doesn't work with npm:@deno/kv in Deno. Mar 1, 2024
@RuiNtD RuiNtD changed the title Typing doesn't work with npm:@deno/kv in Deno. Typing doesn't work with npm:@deno/kv Mar 1, 2024
@oliver-oloughlin
Copy link
Owner

I have been experimenting with the npm package to see if I could figure out compatibility with Node, and wasn't sure how to do it. This is a really good suggestion, I will see if I can fix this issue and make it work.

@oliver-oloughlin
Copy link
Owner

Sadly at this time, it seems the types from the NPM package and the native Deno.Kv types aren't consistent enough to actually make it cross-platform compatible. I tried moving over to using the types from npm:@deno/kv, but this still caused issues when trying to use a Deno.Kv instance with kvdex. As long as this is the case I will be prioritizing native compatibility, and hopefully we will see an improvement on this front in the future with a stable release of Deno KV.

@oliver-oloughlin
Copy link
Owner

oliver-oloughlin commented Mar 5, 2024

Opps, didnt mean to close the issue, we can keep this open until there is some solution.

@oliver-oloughlin
Copy link
Owner

This should now have been fixed as of #205 and release 1.0.0.
Both the native Deno.Kv object and KV from @deno/kv should be compatible.

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

2 participants