Skip to content

Use z.infer to derive TypeScript types from Zod schemas#103

Merged
brandonjpierce merged 2 commits into
mainfrom
feat/pw-infer-ts-from-schema
May 18, 2026
Merged

Use z.infer to derive TypeScript types from Zod schemas#103
brandonjpierce merged 2 commits into
mainfrom
feat/pw-infer-ts-from-schema

Conversation

@tanyafortuna
Copy link
Copy Markdown
Collaborator

This PR replaces ~40 lines of manual TypeScript type definitions with z.infer<typeof schema> to derive types directly from Zod schemas. This eliminates the duplication between validation schemas and TypeScript types, ensuring they can never drift apart. I tweaked some existing tests and added some new ones to verify default button values are applied when omitted and explicit values are preserved.

@tanyafortuna tanyafortuna self-assigned this May 18, 2026
@tanyafortuna
Copy link
Copy Markdown
Collaborator Author

@belsrc @brandonjpierce another one for you! This one removes some type definitions and infers them from the schema instead. Thank you!

@brandonjpierce
Copy link
Copy Markdown
Collaborator

Nice! Same pattern we use in "Definitive React" guide as well 👍

@brandonjpierce brandonjpierce merged commit eb931dc into main May 18, 2026
6 checks passed
@brandonjpierce brandonjpierce deleted the feat/pw-infer-ts-from-schema branch May 18, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants