Function isType

  • Returns true if action has the same type as action creator. Defines Type Guard that lets TypeScript know payload type inside blocks where isType returned true.

    Type Parameters

    • Payload

    Parameters

    Returns action is Action<Payload>

    Example

    const somethingHappened =
    actionCreator<{foo: string}>('SOMETHING_HAPPENED');

    if (isType(action, somethingHappened)) {
    // action.payload has type {foo: string}
    }