say I have a type like so
const values = ["a", "b", "c"];
type Costumer = "costumer1" | "costumer2";
type COSTUMERS: Record<Costumer, string[]> = {
costumer1: values,
contumer2: values,
};
and I want to write this function
function foo(key: string) {
const values = COSTUMERS[key];
if (values === undefined) throw "error";
// use values as string[]
}
how do I make typescript happy? It complains with
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record<Costumer, string[]>'.
I understand the error but I don't know how I could write this in a way that works