Skip to content

Make AbstractSublevel#db type more specific#119

Merged
vweevers merged 1 commit into
Level:mainfrom
stwlam:patch-1
Sep 29, 2025
Merged

Make AbstractSublevel#db type more specific#119
vweevers merged 1 commit into
Level:mainfrom
stwlam:patch-1

Conversation

@stwlam

@stwlam stwlam commented Sep 29, 2025

Copy link
Copy Markdown
Contributor

The getter returns TDatabase["db"]--if TDatabase is an AbstractSublevel--or else TDatabase itself.

@vweevers

Copy link
Copy Markdown
Member

What's the use case?

@stwlam

stwlam commented Sep 29, 2025

Copy link
Copy Markdown
Contributor Author

What's the use case?

Suppose one has a sublevel that is an AbstractSublevel<ClassicLevel, any, any, any> of some kind. It is statically knowable that sublevel.db is an AbstractLevel (since it's a ClassicLevel) and not an AbstractSublevel, so getting the full ClassicLevel interface as a return is type-safe and useful.

@stwlam stwlam marked this pull request as draft September 29, 2025 16:57
@stwlam stwlam marked this pull request as ready for review September 29, 2025 17:06
@stwlam

stwlam commented Sep 29, 2025

Copy link
Copy Markdown
Contributor Author

Sorry, expanded it a bit after a little more testing

The getter returns `TDatabase` if it is an `AbstractLevel`, `TDatabase["db"]` if an `AbstractSublevel`, else some indeterminable kind of `AbstractLevel`.
Comment thread types/abstract-sublevel.d.ts
@vweevers vweevers changed the title Make AbstractSublevel#db have a conditional return type Make AbstractSublevel#db type more specific Sep 29, 2025
@vweevers vweevers merged commit cc290ed into Level:main Sep 29, 2025
6 checks passed
@vweevers

Copy link
Copy Markdown
Member

3.1.1. Thanks for the contribution!

@stwlam stwlam deleted the patch-1 branch September 29, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants