Skip to content

Commit c850c08

Browse files
committed
fix(console): type callback params in cloudflare kv resource
1 parent 7ef79b9 commit c850c08

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

packages/console/resource/resource.node.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ export const waitUntil = async (promise: Promise<any>) => {
66
await promise
77
}
88

9+
type KvBulkGetResult = {
10+
values?: Record<string, string>
11+
}
12+
13+
type KvListResult = {
14+
result: KVNamespaceListResult<unknown, string>["keys"]
15+
}
16+
917
export const Resource = new Proxy(
1018
{},
1119
{
@@ -34,7 +42,9 @@ export const Resource = new Proxy(
3442
keys: Array.isArray(k) ? k : [k],
3543
account_id: accountId,
3644
})
37-
.then((result) => (isMulti ? new Map(Object.entries(result?.values ?? {})) : result?.values?.[k]))
45+
.then((result: KvBulkGetResult) =>
46+
isMulti ? new Map(Object.entries(result.values ?? {})) : result.values?.[k],
47+
)
3848
},
3949
put: (k: string, v: string, opts?: KVNamespacePutOptions) =>
4050
client.kv.namespaces.values.update(namespaceId, k, {
@@ -54,7 +64,7 @@ export const Resource = new Proxy(
5464
account_id: accountId,
5565
prefix: opts?.prefix ?? undefined,
5666
})
57-
.then((result) => {
67+
.then((result: KvListResult) => {
5868
return {
5969
keys: result.result,
6070
list_complete: true,

0 commit comments

Comments
 (0)