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 · 2 comments · May be fixed by #117
Open

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

Swissbite opened this issue Feb 28, 2025 · 2 comments · May be fixed by #117
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
Swissbite pushed a commit to Swissbite/classic-level that referenced this issue Mar 3, 2025
@Swissbite Swissbite linked a pull request Mar 3, 2025 that will close this issue
@Swissbite
Copy link
Author

@vweevers : Added PR #117

Swissbite pushed a commit to Swissbite/classic-level that referenced this issue Mar 6, 2025
Swissbite pushed a commit to Swissbite/classic-level that referenced this issue Mar 6, 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

Successfully merging a pull request may close this issue.

2 participants