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 of get is missing the undefined as a possible return value #116

Open
Swissbite opened this issue Feb 28, 2025 · 1 comment
Open
Labels
bug Something isn't working pull request welcome A pull request is welcome

Comments

@Swissbite
Copy link

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

classic-level/index.d.ts

Lines 51 to 52 in 15eb289

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

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>
@vweevers
Copy link
Member

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

@vweevers vweevers added bug Something isn't working pull request welcome A pull request is welcome labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pull request welcome A pull request is welcome
Projects
None yet
Development

No branches or pull requests

2 participants