Skip to content

InferEventMap

InferEventMap<T> = { [K in keyof T as T[K]["type"]]: InferEventType<T[K]> }

Defined in: zod/src/index.ts:112

Create an event map type from event schema definitions

T extends Record<string, EventSchemaDefinition>

const issueOpened = defineEvent('issue.opened', z.object({ id: z.number() }));
const issueClosed = defineEvent('issue.closed', z.object({ id: z.number() }));
const schemas = { issueOpened, issueClosed };
type GitHubEventMap = InferEventMap<typeof schemas>;
// Results in:
// {
// 'issue.opened': { id: string; type: 'issue.opened'; data: { object: { id: number } } };
// 'issue.closed': { id: string; type: 'issue.closed'; data: { object: { id: number } } };
// }