feat(merge-props): generic over the consumer's props — cast-free call sites#51
Merged
Conversation
… sites mergeProps typed Record<string, unknown> on both ends forced every binding call site into a double cast: framework prop interfaces (no index signature) aren't assignable in, and the anonymous return can't spread onto a typed component. Make it generic (base + react/native/opentui): consumer props pass in as-is and return as the Object.assign-style intersection Props & Record<string, unknown> — assignable to the component's props, library bindings still reachable. Behavior unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
mergePropswas typedRecord<string, unknown> -> Record<string, unknown>, which forces every binding call site into a double cast:Record<string, unknown>This makes it generic across the base (
state-machine-utils) and all three adapters (react / native / opentui):The return is the
Object.assign-style intersection: assignable to the component's props (the JSX spread needs no cast) while the library's bindings stay reachable on the result — purePropswould have hidden them, which the existing tests caught immediately.Type-only; behavior unchanged. Downstream sweep: dunky/ui's react + native dialog bindings drop ~16 casts once this releases.
Test plan
pnpm test:ci— 923 tests, 84 files (2 new type-preservation tests viaexpectTypeOf)pnpm typecheck/pnpm lint/pnpm format:checkpnpm build— all packages🤖 Generated with Claude Code