Is it possible to type guards' { cond }
in xstate 4.32.1 with @xstate/cli
?
#4922
-
In this discussion #2116 it's stated xstate/codegen would take care of it. I imagine it's referring to Given the following dummy machine (and its corresponding Is this possible to achieve? PS: I tried to create a sandbox for this but I couldn't get it to install specifically 4.32.1 nor to run autogen tool const machine = createMachine({
tsTypes: {} as import("./chrisMachine.typegen").Typegen0,
schema: {
context: {} as {},
events: {} as { type: 'CONTINUE', }
},
initial: 'awake',
states: {
awake: {
on: {
CONTINUE: [
{
target: "asleep",
cond: {
type: 'isTiredEnough',
level: 8
}
}
]
}
},
asleep: {
type: "final"
}
},
}, {
guards: {
isTiredEnough: (context, event, { cond }) => {
return cond.level >= 9;
}
},
}); // This file was automatically generated. Edits will be overwritten
export interface Typegen0 {
"@@xstate/typegen": true;
internalEvents: {
"xstate.init": { type: "xstate.init" };
};
invokeSrcNameMap: {};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {};
eventsCausingDelays: {};
eventsCausingGuards: {
isTiredEnough: "CONTINUE";
};
eventsCausingServices: {};
matchesStates: "asleep" | "awake";
tags: never;
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is likely a missing feature in Typegen. Is it possible for you to migrate to XState v5 instead? |
Beta Was this translation helpful? Give feedback.
This is likely a missing feature in Typegen. Is it possible for you to migrate to XState v5 instead?