Skip to content

Commit

Permalink
removed never from ternary check for action creators without payload
Browse files Browse the repository at this point in the history
Handling `never` is not worth the complication
  • Loading branch information
Dudeonyx committed Apr 29, 2019
1 parent 7e29b2f commit 3562ff2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/createSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ type Stringify<T> = T extends string ? T : string
* An action creator atttached to a slice.
*/
export type SliceActionCreator<A> = A extends PayloadAction<infer P, infer T>
? unknown extends P // hacky check for payload type `any`, needed so `any` doesn't trigger the ternary check for undefined
? unknown extends P // hacky check for payload type `any`, needed so `any` doesn't trigger the ternary check for undefined|void
? {
(payload: P): PayloadAction<P, T>
type: T
}
: P extends undefined | never | void
: P extends undefined | void
? {
(): PayloadAction<P, T>
type: T
Expand Down

0 comments on commit 3562ff2

Please sign in to comment.