I've got this generic interface for paginated response:
export interface PaginatedResponse<T> {
pageIndex: number;
pageSize: number;
totalCount: number;
totalPages: number;
items: Array<T>;
}
And then I want to turn it in zod schema for runtime type checks. The approach was like this:
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 type of array should be items in the schema?