// in reducer
switch (action.type) {
case getType(increment):
return state + 1;
default: return state;
}
Change:
- createAction - return action creator instance type access using getType instance method
```ts
const increment = createAction('INCREMENT');
// now to get the type of action creator with imperative API use
expect(increment.getType!()).toBe('INCREMENT');
// or "FP" style
expect(getType(increment)).toBe('INCREMENT');
Update:
added handling of few edge cases
added more test cases and type correctness test cases
New:
const increment = createAction('INCREMENT'); const type: 'INCREMENT' = getType(increment); expect(type).toBe('INCREMENT');
// in reducer switch (action.type) { case getType(increment): return state + 1;
default: return state; }
Update: