feat(types): support pre-typed APIs via signInteractionTrace.withTypes()#11
Merged
Conversation
There was a problem hiding this comment.
This is a great addition, introducing a withTypes method to provide compile-time type safety for interaction traces. The implementation is clean and will certainly improve correctness for consumers. There appear to be a couple of type-level considerations, one that may prevent the API from checking as intended and another related to the effectiveness of a test case.
fde37ff to
c43d3ef
Compare
3 tasks
rfgamaral
approved these changes
Feb 3, 2026
This PR adds compile-time type safety for trace names and their associated details, inspired by Reselect's `withTypes` pattern. This allows consumers to define their valid traces upfront and get autocomplete + error checking throughout their codebase. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c43d3ef to
4dc5271
Compare
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.
This PR adds compile-time type safety for trace names and their associated details, inspired by Reselect's
withTypespattern. This allows consumers to define their valid traces upfront and get autocomplete + error checking throughout their codebase.Stacked on top of #8
Example
Test plan
To verify the type safety works:
Create a custom trace definitions type:
Create a pre-typed function:
Verify TypeScript catches errors:
signTrace('typo trace', ...))signTrace('test trace', { wrong: 123 }))Verify autocomplete:
'test trace'when typing the first argument