Reputation: 187
Let's say I have an enum:
enum AlertAction {
RESET = "RESET",
RESEND = "RESEND",
EXPIRE = "EXPIRE",
}
I want to create multiple actions, as shown below:
type Action<T> = {
type: T;
payload: string;
};
type ActionType =
| Action<Action.RESET>
| Action<Action.RESEND>
| Action<Action.EXPIRE>;
In ActionType
, I wrote the code Action<enum> multiple times.
Is there a way to not repeat writing Action<enum>?
Upvotes: 0
Views: 42
Reputation: 54753
It's straightforward :
type ActionType = Action<AlertAction>
Upvotes: 1