Here is the example of what I want to do:
const obj = {
parent1: {
child1: "child-key1",
child2: "child-key2",
},
parent2: {
child3: "child-key3",
child4: "child-key4",
}
} as const
const func = (
parentKeyName : keyof typeof obj,
childKeyName: keyof typeof obj[parentKeyName]
) => {}
// When I fill first arg, I want code completion to suggest me the list of keys for second arg
func("parent2", "child3")
But the definition of ‘func’ above gives me an error:
Is there any way to use first arg to narrow the type of second arg?
1