Created
August 6, 2020 07:24
-
-
Save Haosvit/410f76943bb022fcf228d20748e302ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActionCreatorBuilder, getType } from 'typesafe-actions'; | |
interface IAppAction { | |
type: string; | |
payload: any; | |
[extra: string]: any; | |
} | |
export function isType<TPayload = any>( | |
action: IAppAction, | |
actionCreator: ActionCreatorBuilder<string, TPayload, any>, | |
): action is ReturnType<typeof actionCreator> { | |
return (action as ReturnType<typeof actionCreator>).type === getType(actionCreator); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment