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.
true
payload
isType
const somethingHappened = actionCreator<{foo: string}>('SOMETHING_HAPPENED'); if (isType(action, somethingHappened)) { // action.payload has type {foo: string} } Copy
const somethingHappened = actionCreator<{foo: string}>('SOMETHING_HAPPENED'); if (isType(action, somethingHappened)) { // action.payload has type {foo: string} }
Returns
trueif action has the same type as action creator. Defines Type Guard that lets TypeScript knowpayloadtype inside blocks whereisTypereturnedtrue.