Skip to content

Instantly share code, notes, and snippets.

Created January 2, 2017 21:29
What would you like to do?
export function apiKey(state: ApiKeyState, action: BaseAction) : ApiKeyState {
let newState: ApiKeyState;
switch (action.type) {
case 'ADD_API_KEY':
newState = Object.assign({}, state); = [,
] as string[];
//More actions handling here
//ERROR: TS2454:Variable 'newState' is used before being assigned.
if (newState) {
return newState;
} else {
return state ? state : API_KEY_INITIAL_STATE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment