I'd like to get an error if two types don't match. I have an object:
const ACTIVITY_ATTRIBUTES = {
onsite: {
id: "applied",
....
},
online: {
id: "applied_online",
....
},
...
} as const
I'd like it to be limited to the strings the server can accept
export type ContactAttribute = "applied" | "applied_online" | "donated" | "messaged" | "reviewed"
I know as const can't go with a type limitation (as const will be ignored). But is there a way to to check for type equality, to enforce that the id property is of type ContactAttribute? Something like:
$Values<typeof ACTIVITY_ATTRIBUTES >["id"] === ContactAttribute