generate schema failed when use Template Literal Types
gezilinll opened this issue · comments
Bug description
generate schema failed when use Template Literal Types
Input
export type Prefix = "large" | "high" | "pos" | "right";
export type Subfix = "back" | "front";
export type Joint = `${Prefix}-${Subfix}`;
Expected output
export const PrefixSchema = z.union([
z.literal("large"),
z.literal("high"),
z.literal("pos"),
z.literal("right"),
]);
export const SubfixSchema = z.union([
z.literal("back"),
z.literal("front"),
]);
export const JointSchema = z.union([
z.literal("large-back"),
z.literal("large-front"),
z.literal("high-back"),
z.literal("high-front"),
z.literal("pos-back"),
z.literal("pos-front"),
z.literal("right-back"),
z.literal("right-front"),
]);
Actual output
export const PrefixSchema = z.union([
z.literal("large"),
z.literal("high"),
z.literal("pos"),
z.literal("right"),
]);
export const SubfixSchema = z.union([
z.literal("back"),
z.literal("front"),
]);
export const JointSchema = z.any();
Versions
- Typescript:
v5.2.2
- Zod:
v3.7.3
feel free to submit a PR