workers-types
workers-types copied to clipboard
`KVNamespaceListResult` more specific types
The two possibilities of
- the listing being complete,
list_complete: true
andcursor
is an empty string, or undefined (not tested) - there are more elements to be returned,
list_complete: false
andcursor
is a string
With a union type of these two, TS compiler would know which case we are in, if we check list_complete
, so cursor wouldn't have to be rechecked.
Docs: https://developers.cloudflare.com/workers/runtime-apis/kv/#pagination
Interface definition: https://github.com/cloudflare/workers-types/blob/38b7e0fba83f01654a00b0d805cd01211a419f3d/overrides/kv.d.ts#L17-L21