A machine's current property type ends up containing extra property names.
const machine = createMachine({
a: state(),
b: state()
});
type Foo = typeof machine['current'];
// Expected:
// type Foo = 'a' | 'b';
// Actual:
// type Foo = 'a' | 'b' | keyof MachineState<string>;
// (Expands to):
// type Foo = 'a' | 'b' | 'final' | 'transitions' | 'immediate' | 'enter';
I believe this is caused by the change to createMachine() type in 4f6fb69. Even though the third type argument to Machine in the return value is unchanged: AllStateKeys<S>, the type of S was changed. Now S is a full MachineStates object, whose values are objects with keys final, transitions, immediate and enter. So when passing a full MachineState to AllStateKeys, it extracts nested keys too. Thus the result is all the state keys plus the nested final, transitions, immediate and enter.
A machine's
currentproperty type ends up containing extra property names.I believe this is caused by the change to
createMachine()type in 4f6fb69. Even though the third type argument toMachinein the return value is unchanged:AllStateKeys<S>, the type ofSwas changed. NowSis a fullMachineStatesobject, whose values are objects with keysfinal,transitions,immediateandenter. So when passing a fullMachineStatetoAllStateKeys, it extracts nested keys too. Thus the result is all the state keys plus the nestedfinal,transitions,immediateandenter.