I found the answer here: https://github.com/microsoft/TypeScript/issues/36444#issuecomment-578572999
I have to convert my class
to type
in order to achieve the solution. Something like this:
type PopulationDto<E> = {
[K in keyof E]: {
path: keyof E;
population?: PopulationDto<
E[K] extends Array<any>
? E[K][number]
: E[K] extends object
? E[K]
: any
>[];
}
}[keyof E];