From 7cb8fe96053f5d0e34c9acc7c0bdb2f385ba8f0b Mon Sep 17 00:00:00 2001 From: mshanemc Date: Wed, 24 Jan 2024 16:11:22 -0600 Subject: [PATCH] refactor: revert breaking change, leave as comments for next major --- src/config/configStore.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/config/configStore.ts b/src/config/configStore.ts index dd313ba26..70a9913f9 100644 --- a/src/config/configStore.ts +++ b/src/config/configStore.ts @@ -20,8 +20,10 @@ import { ConfigContents, ConfigEntry, ConfigValue, Key } from './configStackType export interface ConfigStore

{ // Map manipulation methods entries(): ConfigEntry[]; - get>(key: K, decrypt: boolean): P[K] | undefined; - get(key: string, decrypt: boolean): T | undefined; + // NEXT_RELEASE: update types to specify return can be P[K] | undefined + get>(key: K, decrypt: boolean): P[K]; + // NEXT_RELEASE: update types to specify return can be T | undefined + get(key: string, decrypt: boolean): T; getKeysByValue(value: ConfigValue): Array>; has(key: string): boolean; keys(): Array>; @@ -88,9 +90,13 @@ export abstract class BaseConfigStore< * @param decrypt If it is an encrypted key, decrypt the value. * If the value is an object, a clone will be returned. */ - public get>(key: K, decrypt?: boolean): P[K] | undefined; - public get(key: string, decrypt?: boolean): V | undefined; - public get>(key: K | string, decrypt = false): P[K] | ConfigValue | undefined { + // NEXT_RELEASE: update types to specify return can be | undefined + public get>(key: K, decrypt?: boolean): P[K]; + // NEXT_RELEASE: update types to specify return can be | undefined + // NEXT_RELEASE: consider getting rid of ConfigValue and letting it just use the Key<> approach + public get(key: string, decrypt?: boolean): V; + // NEXT_RELEASE: update types to specify return can be | undefined + public get>(key: K | string, decrypt = false): P[K] | ConfigValue { const rawValue = this.contents.get(key as K); if (this.hasEncryption() && decrypt) { @@ -100,6 +106,7 @@ export abstract class BaseConfigStore< return this.decrypt(rawValue) as P[K] | ConfigValue; } } + // NEXT_RELEASE: update types to specify return can be | undefined return rawValue as P[K] | ConfigValue; }