I have the following type defined:
export type colors = "red" | "blue" | "green"
export interface details {
name: string;
id: string;
}
Is there a way to define a type object that requires all 3 to be defined, without having to loop through each explicitly?
export interface allColors {
red: details;
blue: details;
... etc.
}
as opposed to this type which makes the keys optional?
export type allColors = {
[key in colors]: details;
};
interfacewould require all of them to be set."strict": truein tsconfig.json compilerOptions and are running a relatively recent version of TypeScript