Recently, I created a basic interface to handle paginated responses. It looks like this:
export interface PaginatedResponse<T> {
pageIndex: number;
pageSize: number;
totalCount: number;
totalPages: number;
items: Array<T>;
}
Now, I want to convert it into a zod schema for runtime type validations. Here is the approach I took:
const PaginatedResponseSchema = z.object({
pageIndex: z.number(),
pageSize: z.number(),
totalCount: z.number(),
totalPages: z.number(),
items: z.array(???), // <=
});
export type PaginatedResponse<T> = z.infer<typeof PaginatedResponseSchema>;
What should be the type of array for items in the schema?