chore: minor typings fix

This commit is contained in:
Roman Hotsiy 2018-07-23 11:19:13 +03:00
parent 2ff726649c
commit 21f34b1e59
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -21,12 +21,12 @@ export function isStatusCode(statusCode: string) {
return statusCode === 'default' || isNumeric(statusCode) || isWildcardStatusCode(statusCode);
}
export function getStatusCodeType(statusCode: string, defaultAsError = false): string {
export function getStatusCodeType(statusCode: string | number, defaultAsError = false): string {
if (statusCode === 'default') {
return defaultAsError ? 'error' : 'success';
}
let code = parseInt(statusCode, 10);
let code = typeof statusCode === 'string' ? parseInt(statusCode, 10) : statusCode;
if (isWildcardStatusCode(statusCode)) {
code *= 100; // parseInt('2xx') parses to 2
}