From 73d09045dec38f798d93b28ad11e76f78d65c7cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 12 Sep 2021 14:26:27 +0200 Subject: [PATCH] Remove some any type usage MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/performance/storage/JSONFileStorage.ts | 2 +- src/utils/Configuration.ts | 4 +-- src/utils/Utils.ts | 32 +++++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/performance/storage/JSONFileStorage.ts b/src/performance/storage/JSONFileStorage.ts index 25ba2367..34e25474 100644 --- a/src/performance/storage/JSONFileStorage.ts +++ b/src/performance/storage/JSONFileStorage.ts @@ -53,7 +53,7 @@ export class JSONFileStorage extends Storage { } private checkPerformanceRecordsFile(): void { - if (!this.fd) { + if (!this?.fd) { throw new Error(`${this.logPrefix} Performance records '${this.dbName}' file descriptor not found`); } } diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index f10350eb..2ac26642 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -188,11 +188,11 @@ export default class Configuration { } } - private static objectHasOwnProperty(object: any, property: string): boolean { + private static objectHasOwnProperty(object: unknown, property: string): boolean { return Object.prototype.hasOwnProperty.call(object, property) as boolean; } - private static isUndefined(obj: any): boolean { + private static isUndefined(obj: unknown): boolean { return typeof obj === 'undefined'; } diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 74abb782..73e5e3f9 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -40,20 +40,20 @@ export default class Utils { } } - static convertToDate(value: any): Date { + static convertToDate(value: unknown): Date { // Check if (!value) { - return value; + return value as Date; } // Check Type if (!(value instanceof Date)) { - return new Date(value); + return new Date(value as string); } return value; } - static convertToInt(value: any): number { - let changedValue: number = value; + static convertToInt(value: unknown): number { + let changedValue: number = value as number; if (!value) { return 0; } @@ -63,25 +63,25 @@ export default class Utils { // Check if (Utils.isString(value)) { // Create Object - changedValue = parseInt(value); + changedValue = parseInt(value as string); } return changedValue; } - static convertToFloat(value: any): number { - let changedValue: number = value; + static convertToFloat(value: unknown): number { + let changedValue: number = value as number; if (!value) { return 0; } // Check if (Utils.isString(value)) { // Create Object - changedValue = parseFloat(value); + changedValue = parseFloat(value as string); } return changedValue; } - static convertToBoolean(value: any): boolean { + static convertToBoolean(value: unknown): boolean { let result = false; // Check boolean if (value) { @@ -144,7 +144,7 @@ export default class Utils { return false; } - static isEmptyJSon(document: any): boolean { + static isEmptyJSon(document: unknown): boolean { // Empty? if (!document) { return true; @@ -157,15 +157,15 @@ export default class Utils { return Object.keys(document).length === 0; } - static isString(value: any): boolean { + static isString(value: unknown): boolean { return typeof value === 'string'; } - static isUndefined(value: any): boolean { + static isUndefined(value: unknown): boolean { return typeof value === 'undefined'; } - static isNullOrUndefined(value: any): boolean { + static isNullOrUndefined(value: unknown): boolean { // eslint-disable-next-line no-eq-null, eqeqeq if (value == null) { return true; @@ -173,7 +173,7 @@ export default class Utils { return false; } - static isEmptyArray(object: any): boolean { + static isEmptyArray(object: unknown): boolean { if (!object) { return true; } @@ -183,7 +183,7 @@ export default class Utils { return true; } - static isEmptyObject(obj: any): boolean { + static isEmptyObject(obj: Record): boolean { return !Object.keys(obj).length; } -- 2.34.1