Skip to content

Commit

Permalink
Fixed TS issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jan 31, 2025
1 parent ad23c06 commit babb74d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/xstate-store/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export type Recipe<T, TReturn> = (state: T) => TReturn;

export type EnqueueObject<TEmittedEvent extends EventObject> = {
emit: {
[K in TEmittedEvent['type']]: (
payload: Omit<TEmittedEvent & { type: K }, 'type'>
) => void;
[E in TEmittedEvent as E['type']]: (payload: Omit<E, 'type'>) => void;
};
effect: (fn: () => void) => void;
};
Expand Down Expand Up @@ -109,11 +107,11 @@ export interface Store<
* ```
*/
trigger: {
[K in TEvent['type'] & string]: IsEmptyObject<
Omit<{ type: K } & TEvent, 'type'>
[E in TEvent as E['type'] & string]: IsEmptyObject<
Omit<E, 'type'>
> extends true
? () => Omit<{ type: K } & TEvent, 'type'>
: (eventPayload: Omit<{ type: K } & TEvent, 'type'>) => void;
? () => Omit<E, 'type'>
: (eventPayload: Omit<E, 'type'>) => void;
};
}

Expand Down Expand Up @@ -314,5 +312,5 @@ export type Prop<T, K> = K extends keyof T ? T[K] : never;
export type Cast<A, B> = A extends B ? A : B;

export type EventMap<TEvent extends EventObject> = {
[K in TEvent['type']]: TEvent & { type: K };
[E in TEvent as E['type']]: E;
};

0 comments on commit babb74d

Please sign in to comment.