zod-dynamic-schema-type-inference

Installation
SKILL.md

Zod Dynamic Schema Construction Type Inference Loss

Problem

When building a Zod schema factory that dynamically constructs z.object() from a Record<string, z.ZodType>, TypeScript's z.infer<> produces Record<string, unknown> instead of properly-typed fields. This breaks all downstream type usage — components, server actions, and form handlers that depend on typed schema inference get unknown for every field.

Context / Trigger Conditions

  • Building a schema factory or helper that returns z.ZodObject<Record<string, z.ZodType>>
  • Type error: 'data.fieldName' is of type 'unknown'
  • z.infer<typeof generatedSchema> resolves to Record<string, unknown> in IDE hover
  • Refactoring hand-written Zod schemas to use a centralized factory/generator
  • Using ORM metadata (Prisma, ZenStack, Drizzle) to auto-generate Zod schemas at runtime

Root Cause

Installs
1
GitHub Stars
1
First Seen
Mar 4, 2026
zod-dynamic-schema-type-inference — hankanman/claude-config