I have the following type and interface:
import { FC } from 'react';
export type RuleType =
| 'userId'
| 'userSegment'
| 'userBasketItem'
| 'userPurchases'
| 'lastPurchaseDate'
| 'userPurchasedItem'
| 'userPurchasedGroup'
| 'allUsers';
interface RuleInputs {
userId: FC;
userSegment: FC;
userBasketItem: FC;
userPurchases: FC;
lastPurchaseDate: FC;
userPurchasedItem: FC;
userPurchasedGroup: FC;
allUsers: FC;
}
Instead of typing every key for RuleInputs by hand I would like it to be added dynamically when new values are added to the RuleType union. Is there a way to do this using Typescript or do I need to update both types when RuleType changes?