79411290

Date: 2025-02-04 10:20:48
Score: 1.5
Natty:
Report link

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];
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Tan Nguyen