Skip to content

Instantly share code, notes, and snippets.

@aaronjensen
Last active January 21, 2017 01:21
Show Gist options
  • Save aaronjensen/ece9682ff606ebfc7f0fce4d3508bd7b to your computer and use it in GitHub Desktop.
Save aaronjensen/ece9682ff606ebfc7f0fce4d3508bd7b to your computer and use it in GitHub Desktop.
// This won't type check even when correct
export default function reducer(state: SessionState = initialState, action: SetCurrentUserAction): SessionState {
let newState
switch (action.type) {
case 'SET_CURRENT_USER':
newState = { loaded: true, currentUser: action.payload }
}
return newState
}
// This type checks even when incorrect
export default function reducer(state: SessionState = initialState, action: SetCurrentUserAction): SessionState {
switch (action.type) {
// case 'SET_CURRENT_USER':
case 'BAD':
state = { loaded: true, currentUser: action.payload }
}
return state
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment