feat(core): add actions, guards, delays to SetupTypes interface#5446
Open
cevr wants to merge 1 commit intostatelyai:mainfrom
Open
feat(core): add actions, guards, delays to SetupTypes interface#5446cevr wants to merge 1 commit intostatelyai:mainfrom
cevr wants to merge 1 commit intostatelyai:mainfrom
Conversation
Add type slots for actions, guards, and delays to the SetupTypes interface. This enables explicit type annotations for machines, which helps break TypeScript inference chains in large codebases that can cause performance issues and "excessively large and possibly infinite" type errors. Changes: - Add TAction, TGuard, TDelay type parameters to SetupTypes interface - Add actions, guards, delays properties to SetupTypes - Update MachineTypes to extend SetupTypes with new parameters - Update setup() to pass action/guard/delay types to SetupTypes - Add type tests for new functionality Co-Authored-By: Claude <noreply@anthropic.com>
|
Member
|
cc. @Andarist to take a quick look to see if this is needed |
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
actions,guards, anddelaysto theSetupTypesinterfaceProblem
In large codebases that share types between backend and frontend, TypeScript's inference on actions/guards/delays can cause:
const machine: StateMachine<...> = setup({...}).createMachine({})Solution
Add
actions,guards, anddelaystoSetupTypes(like the existingcontext,events, etc.). This allows users to declare types explicitly rather than relying solely on inference.Changes
types.ts: AddTAction,TGuard,TDelaytype parameters and properties toSetupTypessetup.ts: Pass action/guard/delay types toSetupTypesin thetypesparametersetup.types.test.ts: Add tests for new type slotsTest plan
🤖 Generated with Claude Code