I'm having issues with conditional types.
I require that when filter[triggerType] on AutomationParams changes, filter[triggerId] values also update to the proper kind.
For instance, when filter[triggerType] equals corn, the alternatives for filter[triggerId] are limited to being of the CronTriggerId type.
type TriggerType = 'event' | 'cron' | 'scheduled';
type EventTriggerId = 'extendStayRequired' | 'reservationAccessChanged'
type CronTriggerId = 'reservationsCron';
type ScheduledTriggerId = 'reservationCheckedIn';
type TriggerId<T> = T extends 'event'
? EventTriggerId
: T extends 'cron'
? CronTriggerId
: T extends 'scheduled'
? ScheduledTriggerId
: never;
type AutomationParams = {
'filter[triggerType]': TriggerType;
'filter[triggerId]': TriggerId<TriggerType>;
};
const obj: AutomationParams = {
'filter[triggerType]': 'cron',
'filter[triggerId]': 'extendStayRequired',
};
Additionally, this is the playground.