Skip to content

fix(zod): add explicit type annotations to enum schemas for isolatedDeclarations #1188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aaronshaf
Copy link

Summary

This PR fixes #1187 by adding explicit type annotations to generated Zod enum schemas to make them compatible with TypeScript's isolatedDeclarations compiler option.

Changes

  • Added z.ZodEnum<typeof EnumType> type annotation for regular enums using z.nativeEnum()
  • Added z.ZodEnum<{ VALUE: "VALUE"; ... }> type annotation for enumsAsTypes using z.enum()

Example

Before (causes TS9023 error):

export const StatusSchema = z.nativeEnum(Status);

After (works with isolatedDeclarations):

export const StatusSchema: z.ZodEnum<typeof Status> = z.nativeEnum(Status);

Test plan

  • All existing tests pass (264 tests)
  • Updated test expectations to match new type annotations
  • Verified the generated code includes proper type annotations

Fixes #1187

🤖 Generated with Claude Code

…eclarations

This change adds explicit z.ZodEnum type annotations to all generated enum schemas
to make them compatible with TypeScript's isolatedDeclarations compiler option.

- For regular enums: Added z.ZodEnum<typeof EnumType> annotation
- For enumsAsTypes: Added z.ZodEnum<{ VALUE: "VALUE"; ... }> annotation

Fixes Code-Hex#1187

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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.

Generated enum schemas lack explicit types, causing conflict with isolatedDeclarations
1 participant