Patch Changes
-
#5055
ad38c35c37
Thanks @SandroMaglione! - Updated types ofuseActor
,useMachine
, anduseActorRef
to requireinput
when defined insidetypes/input
.Previously even when
input
was defined insidetypes
,useActor
,useMachine
, anduseActorRef
would not make the input required:const machine = setup({ types: { input: {} as { value: number } } }).createMachine({}); function App() { // Event if `input` is not defined, `useMachine` works at compile time, but risks crashing at runtime const _ = useMachine(machine); return <></>; }
With this change the above code will show a type error, since
input
is now required:const machine = setup({ types: { input: {} as { value: number } } }).createMachine({}); function App() { const _ = useMachine(machine, { input: { value: 1 } // Now input is required at compile time! }); return <></>; }
This avoids runtime errors when forgetting to pass
input
when defined insidetypes
.