What does `type Paths = { [K in keyof T]: K extends string ? T[K] extends object ? `${K}.${Paths}` | K : K : never }[keyof T]` compute?

TypeScript Professional Hard

TypeScript Professional — Hard

What does `type Paths = { [K in keyof T]: K extends string ? T[K] extends object ? `${K}.${Paths}` | K : K : never }[keyof T]` compute?

Key points

  • Generates dot-notation paths to properties at every depth of T
  • Utilizes conditional types to handle different property types
  • Returns a union of all possible path strings
  • Recursively builds paths for nested properties

Ready to go further?

Related questions