feat(typescript-zod): emit literals for single-value enums - #3108
feat(typescript-zod): emit literals for single-value enums#3108louis-bompart wants to merge 3 commits into
Conversation
Generated-output differences37 files differ — 0 modified, 37 new, 0 deleted |
Mh, good question, I was honestly mimicking what's been done for the TypeScript language. |
Generated-output differences42 files differ — 0 modified, 42 new, 0 deleted |
Totally understandable :-). I don't think it's a breaking change, except in the sense that any change is breaking something, so if you wouldn't mind could you remove the option? I'm trying to minimize options. |
|
Done in bb7ff44: removed the |

Description
Emit
z.literal(...)schemas for single-value TypeScript Zod string enums. Multi-value enums continue to usez.enum(...).Related Issue
N/A
Motivation and Context
Single-value enums have a more precise and concise Zod representation. Per maintainer feedback, this behavior is always enabled rather than exposed as another renderer option.
Previous Behaviour / Output
New Behaviour / Output
How Has This Been Tested?
npm run buildnpm run test:unit -- test/unit/typescript-zod-const-enum.test.tsnpx biome check packages/quicktype-core/src/language/TypeScriptZod/TypeScriptZodRenderer.ts packages/quicktype-core/src/language/TypeScriptZod/language.ts test/languages.ts test/unit/typescript-zod-const-enum.test.tsThe focused unit test verifies that a single-value enum emits a literal without any renderer option. The schema fixture continues to cover valid and invalid enum values through the normal TypeScript Zod fixture suite.
Screenshots (if appropriate)
N/A