I know that this question may have been answered elsewhere but in case it wasn't, can someone help me get the type of a nested object? We're talking about an object that has multiple other object but all of them look pretty much the same.
const VALUES = {
currentStreak: {
display: "Current streak",
value: currentStreak,
},
longestStreak: {
display: "Longest streak",
value: longestStreak,
},
contributionsThisYear: {
display: "Contributions this year",
value: contributionsThisYear,
},
totalContributions: {
display: "Total contributions",
value: totalContributions,
},
currentCompany: {
display: "Working at",
value: currentCompany,
},
}
This would be the object and this is what I've got. It works well for the main keys but I want to have the keys of each object typed as well.
export type Something = {
[key in keyof typeof VALUES]: { [key: string]: string | number };
};
How do I get the second part right? So that each object has display and value with value being a number or a string.
Sorry if this is a repeat! I'm hoping to understand this once and for all.