I'm trying to use this type but I can't:
type ROLES = "one" | "two"
type Users = {
name: Record<[key in ROLES]?, User[]>;
};
because it throws with:
Generic type 'Record' requires 2 type argument(s). ts(2314)
Why?
The error message says it all. you have to define two generics, so if you want the key to be a key of ROLES then you need to remove the ? and use Record<ROLES, User[]>. if you want optional entries you can use Partial<Record<ROLES, User[]>>.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With