ActionTypes<A extends Action<any>> Type alias

A TypeScript type alias that uses conditional types (read: magic) to represent the exact (literal) type of an action's type property.

More importantly, this can be used to determine a union type which represents the type string literal types for any action in a given ActionsUnion.

For example,

  // given:
  type MyActions = Action<"BANANA">
                   | ActionWithPayload<"APPLE", boolean>
                   | ActionWithPayload<"ORANGE", number>;
  // then:
  type X = ActionTypes<MyActions>;
  // is equivalent to:
  type X = "BANANA" | "APPLE" | "ORANGE";

ActionTypes = undefined

Defined in

Last Updated: 02 February, 2022