Skip to content

Commit 2024573

Browse files
author
Lenz Weber
committed
simplify type guards
1 parent c4a859b commit 2024573

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

packages/toolkit/src/query/core/buildThunks.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -500,30 +500,20 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
500500
}
501501
}
502502

503-
type CalculatableAction = UnwrapPromise<
504-
ReturnType<ReturnType<QueryThunk>> | ReturnType<ReturnType<MutationThunk>>
505-
>
506503
export function calculateProvidedByThunk(
507-
action: CalculatableAction,
504+
action: UnwrapPromise<
505+
ReturnType<ReturnType<QueryThunk>> | ReturnType<ReturnType<MutationThunk>>
506+
>,
508507
type: 'providesTags' | 'invalidatesTags',
509508
endpointDefinitions: EndpointDefinitions,
510509
assertTagType: AssertTagTypes
511510
) {
512-
const isQuery = (action: CalculatableAction) =>
513-
action.meta.arg.type === 'query'
514-
const isFulfilledQuery = (action: any): action is QueryThunk =>
515-
isQuery(action)
516-
const isFulfilledMutation = (action: any): action is MutationThunk =>
517-
!isQuery(action)
518-
519511
return calculateProvidedBy(
520512
endpointDefinitions[action.meta.arg.endpointName][type],
521513
isFulfilled(action) ? action.payload : undefined,
522514
isRejectedWithValue(action) ? action.payload : undefined,
523515
action.meta.arg.originalArgs,
524-
isAnyOf(isRejected, isFulfilledQuery, isFulfilledMutation)(action)
525-
? action.meta.baseQueryMeta
526-
: undefined,
516+
'baseQueryMeta' in action.meta ? action.meta.baseQueryMeta : undefined,
527517
assertTagType
528518
)
529519
}

0 commit comments

Comments
 (0)