I have this JSON:
const example = {
admin: {
name: "Name",
},
greeting: "Hello",
};
I can get the main keys in TS like this:
type Keys = keyof typeof example;
I can write a function like this:
const myFunc = (key: Keys)=>{
///...
}
And I can call it like this:
myFunc('admin')
And I cannot call it like this:
myFunc('Non-existing key')
How can I write a function like the following and enjoy VS Code’s intellisense, so that it would give me suggestion for name?
myFunc('admin.name')
// OR
myFunc('admin', 'name')