Skip to content

Commit

Permalink
fix #1156: union return values fall back to allowing only single memb…
Browse files Browse the repository at this point in the history
…er (#1449)
  • Loading branch information
phryneas authored Sep 3, 2021
1 parent 0cd6a2e commit e3bc1fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/toolkit/src/createAsyncThunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ type GetSerializedErrorType<ThunkApiConfig> = ThunkApiConfig extends {
? GetSerializedErrorType
: SerializedError

type MaybePromise<T> = T | Promise<T>
type MaybePromise<T> = T | Promise<T> | (T extends any ? Promise<T> : never)

/**
* A type describing the return value of the `payloadCreator` argument to `createAsyncThunk`.
Expand Down
10 changes: 10 additions & 0 deletions packages/toolkit/src/tests/createAsyncThunk.typetest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ const anyAction = { type: 'foo' } as AnyAction
expectType<RejectValue>(unwrapResult(returned))
})()

/**
* regression #1156: union return values fall back to allowing only single member
*/
;(async () => {
const fn = createAsyncThunk('session/isAdmin', async () => {
const response: boolean = false
return response
})
})()

{
interface Item {
name: string
Expand Down

0 comments on commit e3bc1fe

Please sign in to comment.