I have a scenario where I need to dynamically derive the keys/fields of my type based on a generic type.
For instance:
Here are the container interfaces
export interface IUser {
id: BigInt;
name: string;
balance: number;
address: Address;
}
export interface Address {
street: string;
city: string;
zipcode: number;
tags: string[];
}
I would like to create a type that looks like this
const matcher: Matcher<IUser> = {
id: 1
}
This can be achieved using the following implementation of Matcher
export type Matcher<T> = {
[K in keyof T]: (number | string | boolean)
}
However, for a more complex situation like
const deepMatcher: Matcher<IUser> = {
id: 1,
user.address.city: 'San Francisco'
}
How can I modify my model (Matcher) to accommodate this use-case?