In TypeScript is there a way to get the type of a nested property based on some tupel? Given the following example let's say the tupel is ["bs", 0, "c"], then the type should be boolean (or ["bs", 0, "ds", 0, "f"] then number etc.).
interface Foo {
a: string;
bs: {
c: boolean;
ds: {
e: null;
f: number;
}[];
}[];
}
For some context, I want to type a function that takes two paramenters, a path and a value. For some object if the value at the given path is an array, it will push the value parameter. The implementation of this function can be found in this Playround. I was already looking at some solutions, for example in this issue, but I think my problem is a little bit different.