This file contains hidden or 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 { | |
let newState: ApiKeyState; | |
switch (action.type) { | |
case 'ADD_API_KEY': | |
newState = Object.assign({}, state); | |
newState.data.apiKeys = [ | |
...state.data.apiKeys, | |
action.payload.Key | |
] as string[]; |
This file contains hidden or 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 |
This file contains hidden or 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
private usedMb(): number { | |
if (this.props.usedBytes != null) { | |
return (this.props.usedBytes / (1024 * 1024)); | |
} | |
//ERROR: TS2322:Type undefined is not assignable to type number. | |
return undefined; | |
} |
This file contains hidden or 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
private usedMb(): number | undefined { | |
if (this.props.usedBytes != null) { | |
return (this.props.usedBytes / (1024 * 1024)); | |
} | |
return undefined; | |
} |
This file contains hidden or 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
private formatUsedMb(): string { | |
//ERROR: TS2531: Object is possibly undefined | |
return this.usedMb().toFixed(0).toString(); | |
} |
This file contains hidden or 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
private usedMb(): number | undefined { | |
if (this.props.usedBytes) { | |
return (this.props.usedBytes / (1024 * 1024)); | |
} | |
return undefined; | |
} |
This file contains hidden or 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 isNumber(n: any): n is number { | |
return typeof n === "number"; | |
} |
This file contains hidden or 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
private usedMb(): number | undefined { | |
//Using type guard isNumber() | |
return isNumber(this.props.usedBytes) ? | |
(this.props.usedBytes / (1024 * 1024)) : | |
undefined; | |
} |
This file contains hidden or 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
interface Bird { | |
fly(); | |
layEggs(); | |
} | |
interface Fish { | |
swim(); | |
layEggs(); | |
} |
This file contains hidden or 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
private formatUsed(): string { | |
let usedMb = this.usedMb(); | |
return usedMb ? usedMb.toFixed(0).toString() : ''; | |
} |