TypeScript type definition for an object property path [duplicate]
问题 This question already has answers here : Typescript: deep keyof of a nested object (2 answers) Closed 1 year ago . Is it possible to type an array of strings in such a way that the array can only be a valid property path in a given object? The type definition should work for all deeply nested objects. Example: const object1 = { someProperty: true }; const object2 = { nestedObject: object1, anotherProperty: 2 }; type PropertyPath<Type extends object> = [keyof Type, ...Array<string>]; // <--