From 5ee5cf8955a191259aae4deda410b2f9c77bd08a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 3 Apr 2023 14:29:49 +0200 Subject: [PATCH] config-loader: fixes for MergedConfigSource Signed-off-by: Patrik Oldsberg --- .../src/sources/MergedConfigSource.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/config-loader/src/sources/MergedConfigSource.ts b/packages/config-loader/src/sources/MergedConfigSource.ts index d03954fa67..5747669564 100644 --- a/packages/config-loader/src/sources/MergedConfigSource.ts +++ b/packages/config-loader/src/sources/MergedConfigSource.ts @@ -30,8 +30,13 @@ export class MergedConfigSource implements ConfigSource { // An optimization to flatten nested merged sources to avid unnecessary microtasks static #flattenSources(sources: ConfigSource[]): ConfigSource[] { return sources.flatMap(source => { - if (sourcesSymbol in source && Array.isArray(source[sourcesSymbol])) { - return this.#flattenSources(source[sourcesSymbol] as ConfigSource[]); + if ( + sourcesSymbol in source && + Array.isArray((source as any)[sourcesSymbol]) + ) { + return this.#flattenSources( + (source as any)[sourcesSymbol] as ConfigSource[], + ); } return source; }); @@ -41,9 +46,11 @@ export class MergedConfigSource implements ConfigSource { return new MergedConfigSource(this.#flattenSources(sources)); } - private constructor(private readonly sources: ConfigSource[]) {} + [sourcesSymbol]: ConfigSource[]; - [sourcesSymbol] = this.sources; + private constructor(private readonly sources: ConfigSource[]) { + this[sourcesSymbol] = this.sources; + } async *readConfigData( options?: ReadConfigDataOptions,