Skip to content

Commit 5f7f36a

Browse files
committed
Use isAction inside .match so it can handle unknown
1 parent e937083 commit 5f7f36a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/toolkit/src/createAction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Action, UnknownAction } from 'redux'
1+
import type { Action } from 'redux'
22
import type {
33
IsUnknownOrNonInferrable,
44
IfMaybeUndefined,
@@ -84,7 +84,7 @@ export type _ActionCreatorWithPreparedPayload<
8484
*/
8585
export interface BaseActionCreator<P, T extends string, M = never, E = never> {
8686
type: T
87-
match: (action: Action<string>) => action is PayloadAction<P, T, M, E>
87+
match: (action: unknown) => action is PayloadAction<P, T, M, E>
8888
}
8989

9090
/**
@@ -279,8 +279,8 @@ export function createAction(type: string, prepareAction?: Function): any {
279279

280280
actionCreator.type = type
281281

282-
actionCreator.match = (action: Action<string>): action is PayloadAction =>
283-
action.type === type
282+
actionCreator.match = (action: unknown): action is PayloadAction =>
283+
isAction(action) && action.type === type
284284

285285
return actionCreator
286286
}

0 commit comments

Comments
 (0)