interface Obj {
a: any;
b: {
c: any;
d: any;
}
c: {
d: any;
}[];
}
get(obj: Obj, path: string) {
}
I'd like to type the path to force user to pass only keys available in the obj.
get(obj: Obj, path: keyof Obj){} works only for the first level.
Expected result is being able to pass as the path:
a, b, b.c, b.d, c, c[0], c[0].d. Is typescript's way of typing able to solve this problem?