From ae85b3512e8a94e5c66aec8a5e9caa6b8b575137 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 19 Sep 2024 14:46:29 +0200 Subject: [PATCH] refactor: turn on `noImplicitOverride` in TS configuration MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../typescript/http-client-pool/tsconfig.json | 1 + .../express-cluster/tsconfig.json | 1 + .../express-hybrid/tsconfig.json | 1 + .../express-worker_threads/tsconfig.json | 1 + .../fastify-cluster/tsconfig.json | 1 + .../fastify-hybrid/tsconfig.json | 1 + .../fastify-worker_threads/tsconfig.json | 1 + .../typescript/smtp-client-pool/tsconfig.json | 1 + .../ws-cluster/tsconfig.json | 1 + .../ws-hybrid/tsconfig.json | 1 + .../ws-worker_threads/tsconfig.json | 1 + src/pools/cluster/dynamic.ts | 12 +++---- src/pools/cluster/fixed.ts | 2 +- .../fair-share-worker-choice-strategy.ts | 35 ++++++++++--------- ...hted-round-robin-worker-choice-strategy.ts | 31 ++++++++-------- .../least-busy-worker-choice-strategy.ts | 27 +++++++------- .../least-elu-worker-choice-strategy.ts | 19 +++++----- ...hted-round-robin-worker-choice-strategy.ts | 27 +++++++------- src/pools/thread/dynamic.ts | 12 +++---- src/worker/thread-worker.ts | 4 +-- tsconfig.json | 3 +- 21 files changed, 101 insertions(+), 82 deletions(-) diff --git a/examples/typescript/http-client-pool/tsconfig.json b/examples/typescript/http-client-pool/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/http-client-pool/tsconfig.json +++ b/examples/typescript/http-client-pool/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/http-server-pool/express-cluster/tsconfig.json b/examples/typescript/http-server-pool/express-cluster/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/http-server-pool/express-cluster/tsconfig.json +++ b/examples/typescript/http-server-pool/express-cluster/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/http-server-pool/express-hybrid/tsconfig.json b/examples/typescript/http-server-pool/express-hybrid/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/http-server-pool/express-hybrid/tsconfig.json +++ b/examples/typescript/http-server-pool/express-hybrid/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/http-server-pool/express-worker_threads/tsconfig.json b/examples/typescript/http-server-pool/express-worker_threads/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/http-server-pool/express-worker_threads/tsconfig.json +++ b/examples/typescript/http-server-pool/express-worker_threads/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/http-server-pool/fastify-cluster/tsconfig.json b/examples/typescript/http-server-pool/fastify-cluster/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/http-server-pool/fastify-cluster/tsconfig.json +++ b/examples/typescript/http-server-pool/fastify-cluster/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/http-server-pool/fastify-hybrid/tsconfig.json b/examples/typescript/http-server-pool/fastify-hybrid/tsconfig.json index d688c5ce..016d5a66 100644 --- a/examples/typescript/http-server-pool/fastify-hybrid/tsconfig.json +++ b/examples/typescript/http-server-pool/fastify-hybrid/tsconfig.json @@ -10,6 +10,7 @@ "typeRoots": ["./node_modules/@types", "./@types"], "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json b/examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json index d688c5ce..016d5a66 100644 --- a/examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json +++ b/examples/typescript/http-server-pool/fastify-worker_threads/tsconfig.json @@ -10,6 +10,7 @@ "typeRoots": ["./node_modules/@types", "./@types"], "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/smtp-client-pool/tsconfig.json b/examples/typescript/smtp-client-pool/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/smtp-client-pool/tsconfig.json +++ b/examples/typescript/smtp-client-pool/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/websocket-server-pool/ws-cluster/tsconfig.json b/examples/typescript/websocket-server-pool/ws-cluster/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/websocket-server-pool/ws-cluster/tsconfig.json +++ b/examples/typescript/websocket-server-pool/ws-cluster/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/websocket-server-pool/ws-hybrid/tsconfig.json b/examples/typescript/websocket-server-pool/ws-hybrid/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/websocket-server-pool/ws-hybrid/tsconfig.json +++ b/examples/typescript/websocket-server-pool/ws-hybrid/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json b/examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json index 19c730cb..3eddea48 100644 --- a/examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json +++ b/examples/typescript/websocket-server-pool/ws-worker_threads/tsconfig.json @@ -9,6 +9,7 @@ "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true, "strict": true, "skipLibCheck": true } diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index e52e91db..014e3e80 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -49,7 +49,7 @@ export class DynamicClusterPool< } /** @inheritDoc */ - protected checkAndEmitDynamicWorkerCreationEvents (): void { + protected override checkAndEmitDynamicWorkerCreationEvents (): void { if (this.emitter != null) { if (!this.fullEventEmitted && this.full) { this.emitter.emit(PoolEvents.full, this.info) @@ -62,7 +62,7 @@ export class DynamicClusterPool< } /** @inheritDoc */ - protected checkAndEmitDynamicWorkerDestructionEvents (): void { + protected override checkAndEmitDynamicWorkerDestructionEvents (): void { if (this.emitter != null) { if (this.fullEventEmitted && !this.full) { this.emitter.emit(PoolEvents.fullEnd, this.info) @@ -76,17 +76,17 @@ export class DynamicClusterPool< } /** @inheritDoc */ - protected shallCreateDynamicWorker (): boolean { + protected override shallCreateDynamicWorker (): boolean { return (!this.full && this.internalBusy()) || this.empty } /** @inheritDoc */ - protected get backPressure (): boolean { + protected override get backPressure (): boolean { return this.full && this.internalBackPressure() } /** @inheritDoc */ - protected get busy (): boolean { + protected override get busy (): boolean { return this.full && this.internalBusy() } @@ -113,7 +113,7 @@ export class DynamicClusterPool< } /** @inheritDoc */ - protected get type (): PoolType { + protected override get type (): PoolType { return PoolTypes.dynamic } } diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index e4df768e..17b64c30 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -96,7 +96,7 @@ export class FixedClusterPool< } /** @inheritDoc */ - protected setupHook (): void { + protected override setupHook (): void { cluster.setupPrimary({ ...this.opts.settings, exec: this.filePath }) } diff --git a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts index 92c8546c..23f751df 100644 --- a/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/fair-share-worker-choice-strategy.ts @@ -24,23 +24,24 @@ export class FairShareWorkerChoiceStrategy< extends AbstractWorkerChoiceStrategy implements IWorkerChoiceStrategy { /** @inheritDoc */ - public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { - elu: { - aggregate: true, - average: true, - median: false, - }, - runTime: { - aggregate: true, - average: true, - median: false, - }, - waitTime: { - aggregate: true, - average: true, - median: false, - }, - } + public override readonly taskStatisticsRequirements: TaskStatisticsRequirements = + { + elu: { + aggregate: true, + average: true, + median: false, + }, + runTime: { + aggregate: true, + average: true, + median: false, + }, + waitTime: { + aggregate: true, + average: true, + median: false, + }, + } /** @inheritDoc */ public constructor ( diff --git a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts index 36871f3c..0db54c4f 100644 --- a/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts @@ -40,19 +40,20 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< */ private workerNodeVirtualTaskExecutionTime = 0 /** @inheritDoc */ - public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { - elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, - runTime: { - aggregate: true, - average: true, - median: false, - }, - waitTime: { - aggregate: true, - average: true, - median: false, - }, - } + public override readonly taskStatisticsRequirements: TaskStatisticsRequirements = + { + elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, + runTime: { + aggregate: true, + average: true, + median: false, + }, + waitTime: { + aggregate: true, + average: true, + median: false, + }, + } /** @inheritDoc */ public constructor ( @@ -164,7 +165,9 @@ export class InterleavedWeightedRoundRobinWorkerChoiceStrategy< } /** @inheritDoc */ - public setOptions (opts: undefined | WorkerChoiceStrategyOptions): void { + public override setOptions ( + opts: undefined | WorkerChoiceStrategyOptions + ): void { super.setOptions(opts) this.roundWeights = this.getRoundWeights() } diff --git a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts index fba23504..5392cdd2 100644 --- a/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-busy-worker-choice-strategy.ts @@ -23,19 +23,20 @@ export class LeastBusyWorkerChoiceStrategy< extends AbstractWorkerChoiceStrategy implements IWorkerChoiceStrategy { /** @inheritDoc */ - public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { - elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, - runTime: { - aggregate: true, - average: false, - median: false, - }, - waitTime: { - aggregate: true, - average: false, - median: false, - }, - } + public override readonly taskStatisticsRequirements: TaskStatisticsRequirements = + { + elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, + runTime: { + aggregate: true, + average: false, + median: false, + }, + waitTime: { + aggregate: true, + average: false, + median: false, + }, + } /** @inheritDoc */ public constructor ( diff --git a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts index c7b86b8f..8b0548c4 100644 --- a/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/least-elu-worker-choice-strategy.ts @@ -23,15 +23,16 @@ export class LeastEluWorkerChoiceStrategy< extends AbstractWorkerChoiceStrategy implements IWorkerChoiceStrategy { /** @inheritDoc */ - public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { - elu: { - aggregate: true, - average: false, - median: false, - }, - runTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, - waitTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, - } + public override readonly taskStatisticsRequirements: TaskStatisticsRequirements = + { + elu: { + aggregate: true, + average: false, + median: false, + }, + runTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, + waitTime: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, + } /** @inheritDoc */ public constructor ( diff --git a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts index 3cb06272..b3a4f1d8 100644 --- a/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts @@ -29,19 +29,20 @@ export class WeightedRoundRobinWorkerChoiceStrategy< private workerNodeVirtualTaskExecutionTime = 0 /** @inheritDoc */ - public readonly taskStatisticsRequirements: TaskStatisticsRequirements = { - elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, - runTime: { - aggregate: true, - average: true, - median: false, - }, - waitTime: { - aggregate: true, - average: true, - median: false, - }, - } + public override readonly taskStatisticsRequirements: TaskStatisticsRequirements = + { + elu: DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS, + runTime: { + aggregate: true, + average: true, + median: false, + }, + waitTime: { + aggregate: true, + average: true, + median: false, + }, + } /** @inheritDoc */ public constructor ( diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index b184da93..fdf1486e 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -49,7 +49,7 @@ export class DynamicThreadPool< } /** @inheritDoc */ - protected checkAndEmitDynamicWorkerCreationEvents (): void { + protected override checkAndEmitDynamicWorkerCreationEvents (): void { if (this.emitter != null) { if (!this.fullEventEmitted && this.full) { this.emitter.emit(PoolEvents.full, this.info) @@ -62,7 +62,7 @@ export class DynamicThreadPool< } /** @inheritDoc */ - protected checkAndEmitDynamicWorkerDestructionEvents (): void { + protected override checkAndEmitDynamicWorkerDestructionEvents (): void { if (this.emitter != null) { if (this.fullEventEmitted && !this.full) { this.emitter.emit(PoolEvents.fullEnd, this.info) @@ -76,17 +76,17 @@ export class DynamicThreadPool< } /** @inheritDoc */ - protected shallCreateDynamicWorker (): boolean { + protected override shallCreateDynamicWorker (): boolean { return (!this.full && this.internalBusy()) || this.empty } /** @inheritDoc */ - protected get backPressure (): boolean { + protected override get backPressure (): boolean { return this.full && this.internalBackPressure() } /** @inheritDoc */ - protected get busy (): boolean { + protected override get busy (): boolean { return this.full && this.internalBusy() } @@ -113,7 +113,7 @@ export class DynamicThreadPool< } /** @inheritDoc */ - protected get type (): PoolType { + protected override get type (): PoolType { return PoolTypes.dynamic } } diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index cd94753b..85ec8681 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -58,12 +58,12 @@ export class ThreadWorker< /** * @inheritDoc */ - protected handleError (error: Error | string): string { + protected override handleError (error: Error | string): string { return error as string } /** @inheritDoc */ - protected handleKillMessage (message: MessageValue): void { + protected override handleKillMessage (message: MessageValue): void { super.handleKillMessage(message) this.port?.unref() this.port?.close() diff --git a/tsconfig.json b/tsconfig.json index 96f8109e..df26738d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,8 @@ "declarationDir": "./lib/dts", "strict": true, "verbatimModuleSyntax": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "noImplicitOverride": true }, "include": ["**/*.ts"], "exclude": ["node_modules", "lib"] -- 2.34.1