Minor Changes
-
#4547
8e8d2ba38
Thanks @davidkpiano! - AddassertEvent(...)
to help provide strong typings for events that can't be easily inferred, such as events inentry
andexit
actions, or ininvoke.input
.The
assertEvent(event, 'someType')
function will throw if the event is not the expected type. This ensures that theevent
is guaranteed to have that type, and assumes that the event object has the expected payload (naturally enforced by TypeScript).// ... entry: ({ event }) => { assertEvent(event, 'greet'); // event is { type: 'greet'; message: string } assertEvent(event, ['greet', 'notify']); // event is { type: 'greet'; message: string } // or { type: 'notify'; message: string; level: 'info' | 'error' } }, exit: ({ event }) => { assertEvent(event, 'doNothing'); // event is { type: 'doNothing' } }