I'm creating two types KeyPath<Object> and GetValueAtPath<Object, Path>.
KeyPath<Object> — takes an object type and generates an array type of all possible elements to reach a certain value in the object. Think "address.city" in a type:
type Person {
name: string;
address: {
street: string;
city: string
}
}
...but instead of a string, you use an array: ['address', 'city']. Why? I want to support symbols since object keys can be symbols.
GetValueAtPath<Object, Path> — takes an object type and path, and should return the type of the value at that path.
I'm trying to fix the error on line 8 in this index.ts file.
There's another utility type there, DeepBoolean<Object>, which takes an object type and returns another type that expects the value of every property of Object to be optional boolean.
On line 8 in the linked file above, I'm getting this:
Argument of type 'boolean' is not assignable to parameter of type 'GetValueAtPath<DeepBoolean<Input>, KeyPath<DeepBoolean<Input>>>'.
...and I have been unable to spot what I'm doing wrong.
Any leads will be appreciated.