Skip to content

feat(Indexes): method generic types for better DX#224

Closed
ShaMan123 wants to merge 2 commits into
ThatOpen:mainfrom
ShaMan123:feat/index-generics
Closed

feat(Indexes): method generic types for better DX#224
ShaMan123 wants to merge 2 commits into
ThatOpen:mainfrom
ShaMan123:feat/index-generics

Conversation

@ShaMan123
Copy link
Copy Markdown
Contributor

@ShaMan123 ShaMan123 commented May 23, 2026

Description

Add generic types to index read methods for ease of use

Before

const keys = model.getIndexKeys(name) as Uint32Array

After

const keys = model.getIndexKeys<number>(name)

Additional context

#215 needs to be patched with a generic type


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming (e.g. feat(examples): add hello-world example).
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link
Copy Markdown
Contributor Author

@ShaMan123 ShaMan123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready

agviegas added a commit that referenced this pull request May 29, 2026
Add generic type params to the index read methods so callers no longer
need manual casts. Extends the generics to the getIndexKey/getIndexValues
helpers from #215, keeps getInverseIndexEntry's nullable return honest,
and fixes a latent getValues type error.

Co-Authored-By: ShaMan123 <34343793+ShaMan123@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@agviegas
Copy link
Copy Markdown
Contributor

Thanks @ShaMan123! This landed on main in 1d1db70.

Since #215 had already merged and touched the same methods, I rebased your generics on top of it and extended them to the getIndexKey / getIndexValues helpers it added, so the whole index read API is consistent. I also kept getInverseIndexEntry's return type nullable (it returns null in a few runtime paths), and folded in a small fix for a getValues type error.

Closing as merged via squash. Much appreciated!

@agviegas agviegas closed this May 29, 2026
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