You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagine a repository of state machines that have some subset of state/event names in common, but at the same time are specialised to handle different things.
Is it possible to specify a Typescript supertype for these machines?
I tried ReturnType<typeof createActor(...)> with a machine definition containing the common states and events, but Typescript is quick to point out that specialised machines are not assignable to the supertype:
Types of property config are incompatible.
Types of property initial are incompatible.
Type { type: "COMMON_STATE_1"; } | { type: "COMMON_STATE_2"; } | { type: "SPECIALIZED_STATE_1"; } is not assignable to type { type: "COMMON_STATE_1"; } | { type: "COMMON_STATE_2"; }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Imagine a repository of state machines that have some subset of state/event names in common, but at the same time are specialised to handle different things.
Is it possible to specify a Typescript supertype for these machines?
I tried
ReturnType<typeof createActor(...)>
with a machine definition containing the common states and events, but Typescript is quick to point out that specialised machines are not assignable to the supertype:config
are incompatible.initial
are incompatible.{ type: "COMMON_STATE_1"; } | { type: "COMMON_STATE_2"; } | { type: "SPECIALIZED_STATE_1"; }
is not assignable to type{ type: "COMMON_STATE_1"; } | { type: "COMMON_STATE_2"; }
Beta Was this translation helpful? Give feedback.
All reactions