Using TOGGLE machine as per apresentation but using typescript #1603
Replies: 3 comments 2 replies
-
✏️ Please create a CodeSandbox (XState TypeScript template) reproduction of this. Thanks! |
Beta Was this translation helpful? Give feedback.
-
It seems that this only might become possible in 4.1 with template literal types: https://devblogs.microsoft.com/typescript/announcing-typescript-4-1-beta/#template-literal-types |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for the answers. @davidkpiano sandbox added: https://codesandbox.io/s/friendly-bell-0kykv?file=/src/index.tsx @Andarist you're right, maybe only in typescript 4.1 I'll manage to make the problem go away... |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm trying to implement some toggle machine as shown in the presentation "Standing on the sholders of giants".
I can't find a way to map the actions to the event with typescript:
I think that the ToggleEvent should be ToggleEvent to have the type mutable, but if I do this, the actions are still wrong because it is string and will never be of type T...
There's another way to do something like this and make the typings happy?
EDIT:
CodeSandbox of the problem: https://codesandbox.io/s/friendly-bell-0kykv?file=/src/index.tsx
Thanks,
Mario
Beta Was this translation helpful? Give feedback.
All reactions