I have single type, I would like to reuse this type for concatenation data:
interface MetaData {
user: {
id: string;
fullName: string;
},
stats: {
following: number;
},
another: {
any: any;
}
}
I would like to combine some nested type by keys
(Ex: type Profile = PickAllNestedKey<MetaData, 'user' | 'stats'>
I have to try this code but it can be Pick only single key
type NestedPartial<T, K extends keyof T> = {
[P in keyof T[K]]: T[K][P];
};
type Profile = NestedPartial<Metadata, 'user'>;
Expected type like:
interface Profile {
id: string;
fullName: string;
following: number;
}