ts-to-zod
ts-to-zod copied to clipboard
Support nested namespaces
Feature description
I saw namespace support was added a while back but using ts-to-zod
on my project doesn't generate schemas from types within nested namespaces.
I am willing to implement this feature if you'll point me in the right direction.
Input
type Post = {
id: string;
authorId: string;
title: string;
body: string;
}
export namespace v1 {
export namespace GetPosts {
export type RequestParams = { authorId: string };
export type ResponseBody = { posts: Post[] };
}
}
Output
// This type is generated as expected
const postSchema = z.object({
id: z.string(),
authorId: z.string(),
title: z.string(),
body: z.string()
});
// These are not generated
const v1GetPostsRequestParamsSchema = z.object({ authorId: z.string() });
const v1GetPostsResponseBodySchema = z.object({ posts: postSchema.array() });