Strict types in RemoteConfig
This commit is contained in:
parent
a3065796fe
commit
86e6c2499c
1 changed files with 8 additions and 3 deletions
|
@ -10,6 +10,7 @@ import { parseIntOrThrow } from './util/parseIntOrThrow';
|
|||
import { SECOND, HOUR } from './util/durations';
|
||||
import * as Bytes from './Bytes';
|
||||
import { uuidToBytes } from './util/uuidToBytes';
|
||||
import { dropNull } from './util/dropNull';
|
||||
import { HashType } from './types/Crypto';
|
||||
import { getCountryCode } from './types/PhoneNumber';
|
||||
|
||||
|
@ -54,7 +55,7 @@ type ConfigValueType = {
|
|||
name: ConfigKeyType;
|
||||
enabled: boolean;
|
||||
enabledAt?: number;
|
||||
value?: unknown;
|
||||
value?: string;
|
||||
};
|
||||
export type ConfigMapType = {
|
||||
[key in ConfigKeyType]?: ConfigValueType;
|
||||
|
@ -105,7 +106,11 @@ export const refreshRemoteConfig = async (
|
|||
const oldConfig = config;
|
||||
config = newConfig.reduce((acc, { name, enabled, value }) => {
|
||||
const previouslyEnabled: boolean = get(oldConfig, [name, 'enabled'], false);
|
||||
const previousValue: unknown = get(oldConfig, [name, 'value'], undefined);
|
||||
const previousValue: string | undefined = get(
|
||||
oldConfig,
|
||||
[name, 'value'],
|
||||
undefined
|
||||
);
|
||||
// If a flag was previously not enabled and is now enabled,
|
||||
// record the time it was enabled
|
||||
const enabledAt: number | undefined =
|
||||
|
@ -115,7 +120,7 @@ export const refreshRemoteConfig = async (
|
|||
name: name as ConfigKeyType,
|
||||
enabled,
|
||||
enabledAt,
|
||||
value,
|
||||
value: dropNull(value),
|
||||
};
|
||||
|
||||
const hasChanged =
|
||||
|
|
Loading…
Reference in a new issue