classic-level icon indicating copy to clipboard operation
classic-level copied to clipboard

Typing of `get` is missing the `undefined` as a possible return value

Open Swissbite opened this issue 11 months ago • 2 comments

The Typings is assuming that the return value of get is always of the type stored in the database. But in fact, if a key is not set, then the return value is undefined.

So instead of https://github.com/Level/classic-level/blob/15eb2893086ff52f6ce5b2b79a21ca6340b966fc/index.d.ts#L51-L52

I would suggest to adapt it to

  get (key: KDefault): Promise<VDefault | undefined>
  get<K = KDefault, V = VDefault> (key: K, options: GetOptions<K, V>): Promise<V | undefined>

Swissbite avatar Feb 28 '25 07:02 Swissbite

Agreed. We did that in abstract-level but forgot to copy it to here. PR welcome.

vweevers avatar Feb 28 '25 08:02 vweevers

@vweevers : Added PR #117

Swissbite avatar Mar 06 '25 07:03 Swissbite