Skip to content

Commit

Permalink
types makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Mar 16, 2024
1 parent 044bfbc commit dedadf1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/joke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const jokeMachine = setup({
lastRating: number | null;
loader: string | null;
},
events: eventSchemas.type,
events: eventSchemas.types,
},
actors: {
getJokeCompletion,
Expand Down
2 changes: 1 addition & 1 deletion examples/numberGuesser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const machine = setup({
answer: number;
},
input: {} as { answer: number },
events: eventSchemas.type,
events: eventSchemas.types,
},
schemas: eventSchemas,
actors: {
Expand Down
4 changes: 2 additions & 2 deletions examples/ticTacToe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const eventSchemas = defineEvents({
reset: z.object({}).describe('Reset the game to the initial state'),
});

eventSchemas.type;
eventSchemas.types;

interface GameContext {
board: (Player | null)[];
Expand Down Expand Up @@ -96,7 +96,7 @@ export const ticTacToeMachine = setup({
schemas: eventSchemas,
types: {
context: {} as GameContext,
events: eventSchemas.type,
events: eventSchemas.types,
},
actors: {
bot,
Expand Down
2 changes: 1 addition & 1 deletion examples/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const machine = setup({
history: string[];
count: number;
},
events: events.type,
events: events.types,
},
actors: {
getWeather,
Expand Down
2 changes: 1 addition & 1 deletion examples/wordGuesser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const context = {
const wordGuesserMachine = setup({
types: {
context: {} as typeof context,
events: events.type,
events: events.types,
},
actors: {
getFromTerminal,
Expand Down
4 changes: 2 additions & 2 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ZodEventTypes = {
export function defineEvents<const TEventSchemas extends ZodEventTypes>(
events: TEventSchemas
): {
type: Values<{
types: Values<{
[K in keyof TEventSchemas]: {
type: K;
} & TypeOf<TEventSchemas[K]>;
Expand All @@ -20,7 +20,7 @@ export function defineEvents<const TEventSchemas extends ZodEventTypes>(
};
} {
return {
type: {} as any,
types: {} as any,
schemas: createZodEventSchemas(events),
};
}

0 comments on commit dedadf1

Please sign in to comment.