From e7c0fce05d773fcc1dd2fb285f824808a5dee243 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 17 Jul 2023 12:15:37 +0200 Subject: [PATCH] refactor: improve configuration section typing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Configuration.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 66abd3e1..54f6b745 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -22,6 +22,12 @@ import { } from '../types'; import { WorkerConstants, WorkerProcessType } from '../worker'; +type ConfigurationSectionType = + | LogConfiguration + | StorageConfiguration + | WorkerConfiguration + | UIServerConfiguration; + export class Configuration { private static configurationFile = join( dirname(fileURLToPath(import.meta.url)), @@ -33,7 +39,7 @@ export class Configuration { private static configurationData: ConfigurationData | null = null; private static configurationSectionCache = new Map< ConfigurationSection, - LogConfiguration | StorageConfiguration | WorkerConfiguration | UIServerConfiguration + ConfigurationSectionType >([ [ConfigurationSection.log, Configuration.buildLogSection()], [ConfigurationSection.performanceStorage, Configuration.buildPerformanceStorageSection()], @@ -51,7 +57,9 @@ export class Configuration { Configuration.configurationChangeCallback = cb; } - public static getConfigurationSection(sectionName: ConfigurationSection): T { + public static getConfigurationSection( + sectionName: ConfigurationSection, + ): T { if (!Configuration.configurationSectionCache.has(sectionName)) { switch (sectionName) { case ConfigurationSection.log: -- 2.34.1