If the types do not match, I want to receive an error. Here is an example of an object:
const ACTIVITY_ATTRIBUTES = {
onsite: {
id: "applied",
....
},
online: {
id: "applied_online",
....
},
...
} as const
I want to restrict it to only strings that the server can accept
export type ContactAttribute = "applied" | "applied_online" | "donated" | "messaged" | "reviewed"
I understand that using 'as const' cannot be combined with a type constraint (as const will be ignored). Is there a way to ensure that the 'id' property matches the specified ContactAttribute type? Something like:
$Values<typeof ACTIVITY_ATTRIBUTES >["id"] === ContactAttribute