Let's suppose I have the following object type:
type Test = {
date: Date
num: number
str: string
}
As you can see there is a Date type that I want to convert to a string ("serialize"), so I created the following Generic Type:
type Serializer<T extends {[key: string]: unknown}> = {
[key in keyof T]: T[key] extends Date ? string : T[key]
}
Which does the job very well, you can check this playground link.
But know, what if I have a Test[] type, what generic type could help me "serialize" this data type?

type Result = Serializer<Test>[]to get it as array? Why would you want a serializer generic that takes in an array type?Test[]type, but I also have a method that "serialize" thatTest[]object and transforms theDateto astring, but unfortunately TS does not infer it, so I have to cast it manually.