interface Scores extends Record<string, number> {
math: number;
english: number;
science: number;
}
// @ts-expect-error science is missing!
const scores: Scores = {
math: 95,
english: 90,
};
scores.athletics = 100;
scores.french = 75;
scores.spanish = 70;
I extended Record (but then realized it was a type alias, not an interface...and it worked!). Thought it was interesting to discover and might be worth adding in to 085 as another alternate solution since this seems to be a modern TypeScript pattern people take advantage of.
Not sure if this comes up later in a different module (only halfway through so far)!
I extended Record (but then realized it was a type alias, not an interface...and it worked!). Thought it was interesting to discover and might be worth adding in to
085as another alternate solution since this seems to be a modern TypeScript pattern people take advantage of.Not sure if this comes up later in a different module (only halfway through so far)!