I want to get the union of all they keys of my object recursively that is separated by period.
For example:
type User = {
name: string;
age: number;
work: {
company: string;
position: string;
}
}
I want to get 'name' | 'age' | 'work' | 'work.company' | 'work.position'
;
This is my initial code:
type RecursiveKeys<T> = T extends number | string | boolean ? T : {[K in keyof T]: `${K}.${RecursiveKeys<T[K]>}`}[keyof T]
I suspect my mistake is in this part of my code T extends number | string | boolean
. I'm not sure what condition shall I put to end my recursive