FIX: TS2454: Variable 'newState' is used before being assigned.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function apiKey(state: ApiKeyState, action: BaseAction) : ApiKeyState { | |
//Assigning variable here. | |
let newState: ApiKeyState = state; | |
switch (action.type) { | |
case 'ADD_API_KEY': | |
newState = Object.assign({}, state); | |
newState.data.apiKeys = [ | |
...state.data.apiKeys, | |
action.payload.Key | |
] as string[]; | |
break; | |
//More actions handling here | |
//... | |
} | |
//Using only newState in return. | |
return newState ? newState : API_KEY_INITIAL_STATE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could even shorten line 18 to the following: