Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

KV Namespace list method signature confusion #27

Open
adamjakab opened this issue Nov 23, 2020 · 1 comment · May be fixed by #32
Open

KV Namespace list method signature confusion #27

adamjakab opened this issue Nov 23, 2020 · 1 comment · May be fixed by #32

Comments

@adamjakab
Copy link

The issue is with the list method signature (which is actually correct in the docblock above it).
NAMESPACE.list({prefix?: string, limit?: number, cursor?: string})

If I call the list method like this:
KVNAMESPACE.list('my_prefix').then((mylist) => {...
then it compiles but during execution it thorows the following error:
TypeError: Failed to execute 'list' on 'KvNamespace': parameter 1 is not of type 'ListOptions'.

If I call the list method like this:
KVNAMESPACE.list({prefix: 'my_prefix'}).then((mylist) => {...
then my code won't compile becasue I get:
Error:(35, 25) TS2345: Argument of type '{ prefix: string; }' is not assignable to parameter of type 'string'.

only if i do:

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
KVNAMESPACE.list({ prefix: prefix }).then((mylist) => {...

then it will run.

@marcelduin
Copy link

I have the same issue.

Changing the list type definition on R668 of the above reference to a single any argument makes it work. But of course it's better to type the argument.

13rac1 added a commit that referenced this issue Jun 4, 2021
@13rac1 13rac1 linked a pull request Jun 4, 2021 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants