Make accessor required for table-level index defs in typescript#4525
Merged
clockwork-labs-bot merged 8 commits intomasterfrom Mar 3, 2026
Merged
Make accessor required for table-level index defs in typescript#4525clockwork-labs-bot merged 8 commits intomasterfrom
accessor required for table-level index defs in typescript#4525clockwork-labs-bot merged 8 commits intomasterfrom
Conversation
accessor required for table-level index defs in typescript
Shubham8287
approved these changes
Mar 3, 2026
Collaborator
Author
|
@Shubham8287 has approved (1). I've added @coolreader18 for review of (2). |
Centril
pushed a commit
that referenced
this pull request
Mar 3, 2026
) # Description of Changes This patch contains two main changes: 1. It makes `accessor` a required argument for table-level index defs in typescript to align with rust. 2. It removes unsound index typing in the TypeScript bindings by splitting index data into two explicit representations: - `indexes`: declarative user config (`IndexOpts`) used for type inference - `resolvedIndexes`: normalized runtime metadata (`UntypedIndex`) derived from `RawTableDefV10` `TableCacheImpl` now builds index accessors from `resolvedIndexes` instead of re-casting `indexes` at runtime. This addressed the following comment: ``` // TODO: horrible horrible horrible. we smuggle this `Array<UntypedIndex>` // by casting it to an `Array<IndexOpts>` as `TableToSchema` expects. // This is then used in `TableCacheImpl.constructor` and who knows where else. // We should stop lying about our types. ``` > Why? We were conflating two different concepts under `tableDef.indexes`: 1. declared table-level index options authored by users 2. resolved runtime index definitions (including field-level inferred indexes) This required unsafe casts (`T['idxs']` / `UntypedIndex`) and made the type model unsound. Note, (2) was largely ai assisted. # API and ABI breaking changes Technically breaks the module api, although I believe this is the behavior that is outlined in the spec, and so the current behavior should really be considered a bug. # Expected complexity level and risk 2 # Testing Added unit tests covering the following: 1. Table-level explicit index without accessor throws. 2. Table-level duplicate accessor throws. 3. Table-level explicit accessor is accepted and used. 4. Field-level `.index(...)` derives accessor from the field name (`displayName`).
1 task
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 4, 2026
# Description of Changes Make `Accessor` a required argument for table-level index defs in C# to align with rust and typescript. The same change was done for typescript in #4525. # API and ABI breaking changes Technically breaks the module api, although I believe this is the behavior that is outlined in the spec, and so the current behavior should really be considered a bug. # Expected complexity level and risk 1 # Testing Added negative compile tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Changes
This patch contains two main changes:
It makes
accessora required argument for table-level index defs in typescript to align with rust.It removes unsound index typing in the TypeScript bindings by splitting index data into two explicit representations:
indexes: declarative user config (IndexOpts) used for type inferenceresolvedIndexes: normalized runtime metadata (UntypedIndex) derived fromRawTableDefV10TableCacheImplnow builds index accessors fromresolvedIndexesinstead of re-castingindexesat runtime.This addressed the following comment:
We were conflating two different concepts under
tableDef.indexes:This required unsafe casts (
T['idxs']/UntypedIndex) and made the type model unsound.Note, (2) was largely ai assisted.
API and ABI breaking changes
Technically breaks the module api, although I believe this is the behavior that is outlined in the spec, and so the current behavior should really be considered a bug.
Expected complexity level and risk
2
Testing
Added unit tests covering the following:
.index(...)derives accessor from the field name (displayName).