Skip to content

Commit

Permalink
revert changes, just change return type of single-argument `fulfillWi…
Browse files Browse the repository at this point in the history
…thValue` signature
  • Loading branch information
phryneas committed Nov 10, 2022
1 parent 8909f10 commit 73cd603
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions packages/toolkit/src/createAsyncThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export type BaseThunkAPI<
>
fulfillWithValue: IsUnknown<
FulfilledMeta,
<FulfilledValue>(
value: FulfilledValue
) => FulfillWithMeta<FulfilledValue, FulfilledMeta>,
<FulfilledValue>(value: FulfilledValue) => FulfilledValue,
<FulfilledValue>(
value: FulfilledValue,
meta: FulfilledMeta
Expand Down Expand Up @@ -405,18 +403,16 @@ export type AsyncThunk<
Returned,
ThunkArg,
ThunkApiConfig extends AsyncThunkConfig
> = [Returned] extends [FulfillWithMeta<infer P, infer M>]
? AsyncThunk<P, ThunkArg, ThunkApiConfig & { fulfilledMeta: M }>
: AsyncThunkActionCreator<Returned, ThunkArg, ThunkApiConfig> & {
pending: AsyncThunkPendingActionCreator<ThunkArg, ThunkApiConfig>
rejected: AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>
fulfilled: AsyncThunkFulfilledActionCreator<
Returned,
ThunkArg,
ThunkApiConfig
>
typePrefix: string
}
> = AsyncThunkActionCreator<Returned, ThunkArg, ThunkApiConfig> & {
pending: AsyncThunkPendingActionCreator<ThunkArg, ThunkApiConfig>
rejected: AsyncThunkRejectedActionCreator<ThunkArg, ThunkApiConfig>
fulfilled: AsyncThunkFulfilledActionCreator<
Returned,
ThunkArg,
ThunkApiConfig
>
typePrefix: string
}

type OverrideThunkApiConfigs<OldConfig, NewConfig> = Id<
NewConfig & Omit<OldConfig, keyof NewConfig>
Expand Down Expand Up @@ -696,12 +692,19 @@ If you want to use the AbortController to react to \`abort\` events, please cons
}
}

return Object.assign(actionCreator as any, {
pending,
rejected,
fulfilled,
typePrefix,
})
return Object.assign(
actionCreator as AsyncThunkActionCreator<
Returned,
ThunkArg,
ThunkApiConfig
>,
{
pending,
rejected,
fulfilled,
typePrefix,
}
)
}
createAsyncThunk.withTypes = () => createAsyncThunk

Expand Down

0 comments on commit 73cd603

Please sign in to comment.