From 3f5f43933aca7def019514e4844b324408dfa51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Thu, 10 Apr 2025 10:44:04 +0200 Subject: [PATCH] fix: flag-resolver context type --- src/lib/types/experimental.ts | 5 ++--- src/lib/util/flag-resolver.test.ts | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index a87021c56a..e28beeec4f 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -1,6 +1,7 @@ import { PayloadType, type Variant } from 'unleash-client'; import { parseEnvVarBoolean } from '../util'; import { getDefaultVariant } from 'unleash-client/lib/variant'; +import type { Context } from '../features/playground/feature-evaluator'; export type IFlagKey = | 'accessLogs' @@ -345,9 +346,7 @@ export interface IExperimentalOptions { externalResolver: IExternalFlagResolver; } -export interface IFlagContext { - [key: string]: string; -} +export interface IFlagContext extends Context {} export interface IFlagResolver { getAll: (context?: IFlagContext) => IFlags; diff --git a/src/lib/util/flag-resolver.test.ts b/src/lib/util/flag-resolver.test.ts index e63adc56db..ea9a6c3c33 100644 --- a/src/lib/util/flag-resolver.test.ts +++ b/src/lib/util/flag-resolver.test.ts @@ -244,7 +244,7 @@ test('should call external resolver getStaticContext ', () => { return getDefaultVariant(); }, getStaticContext: () => { - return { clientId: 'red' }; + return { properties: { clientId: 'red' } }; }, }; @@ -264,5 +264,7 @@ test('should call external resolver getStaticContext ', () => { const resolver = new FlagResolver(config as IExperimentalOptions); - expect(resolver.getStaticContext()).toStrictEqual({ clientId: 'red' }); + expect(resolver.getStaticContext()).toStrictEqual({ + properties: { clientId: 'red' }, + }); });