Open EdwardZZZ opened 3 weeks ago
type NestedObject = {
prop1: {
nestedProp1: string;
nestedProp2: number;
};
prop2: string;
};
type Subtract<A extends number, B extends number> =
[...Array<A>, ...Array<B>] extends [...Array<infer L>]
? L
: never;
type ExtractKeys<T, Depth extends number = 10> = [Depth] extends [never]
? never
: T extends object
? keyof T | {
[K in keyof T]: T[K] extends infer U
? U extends object
? ExtractKeys<U, Subtract<Depth, 1>>
: never
: never;
}[keyof T]
: never;
type AllKeys = ExtractKeys<NestedObject>;