Skip to content

Commit

Permalink
Play with type tests a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jan 25, 2019
1 parent 7ae643d commit 4c85493
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions type-tests/files/createSlice.typetest.ts
Expand Up @@ -2,13 +2,16 @@ import {
AnyAction,
createSlice,
PayloadAction,
Reducer
Reducer,
createAction
} from 'redux-starter-kit'

/*
* Test: createSlice() infers the returned slice's type.
*/
{
const firstAction = createAction<{ count: number }>('FIRST_ACTION')

const slice = createSlice({
slice: 'counter',
initialState: 0,
Expand All @@ -17,7 +20,8 @@ import {
decrement: (state: number, action) => state - action.payload
},
extraReducers: {
"OTHER_ACTION_TYPE" : (state : number, action ) => state + action.payload.count
[firstAction.type]: (state: number, action) =>
state + action.payload.count
}
})

Expand Down

0 comments on commit 4c85493

Please sign in to comment.