We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 00ff8a7 commit 46cfb07Copy full SHA for 46cfb07
packages/xstate-store/test/store.test.ts
@@ -376,6 +376,26 @@ it('events can be emitted with no payload', () => {
376
expect(spy).toHaveBeenCalledWith({ type: 'incremented' });
377
});
378
379
+it('events can be emitted with optional payloads (type check)', () => {
380
+ createStore({
381
+ emits: {
382
+ optionalPayload: (_: { payload?: string }) => {}
383
+ },
384
+ context: {},
385
+ on: {
386
+ inc: (_ctx, _ev, enq) => {
387
+ enq.emit
388
+ // @ts-expect-error
389
+ .optionalPayload();
390
+
391
+ enq.emit.optionalPayload({ payload: 'hello' });
392
393
+ enq.emit.optionalPayload({});
394
+ }
395
396
+ });
397
+});
398
399
it('effects can be enqueued', async () => {
400
const store = createStore({
401
context: {
0 commit comments