Skip to content

Commit 2d147ec

Browse files
committed
fix: typing for evalation details for client side sdks
1 parent 2bfc2e8 commit 2d147ec

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

packages/sdk/react-native/src/hooks/variation/LDEvaluationDetail.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1-
import { LDEvaluationDetailTyped as CommonLDEvaluationDetailTyped, LDEvaluationReason, } from '@launchdarkly/js-client-sdk-common';
1+
import {
2+
LDEvaluationDetail as CommonDetail,
3+
LDEvaluationDetailTyped as CommonDetailTyped,
4+
LDEvaluationReason,
5+
} from '@launchdarkly/js-sdk-common';
6+
7+
// Implementation note: In client-side SDKs the reason is optional. The common type, which is also
8+
// used by server SDKs, has a required reason. This file contains a client specific
9+
// LDEvaluationDetail which has an optional reason.
10+
11+
// TODO: On major version change "reason" to be optional instead of nullable.
212

313
/**
414
* An object that combines the result of a feature flag evaluation with information about
515
* how it was calculated.
616
*
7-
* This is the result of calling detailed variation methods.
17+
* This is the result of calling `LDClient.variationDetail`.
18+
*/
19+
export type LDEvaluationDetail = Omit<CommonDetail, 'reason'> & {
20+
/**
21+
* An optional object describing the main factor that influenced the flag evaluation value.
22+
*/
23+
reason: LDEvaluationReason | null;
24+
};
25+
26+
/**
27+
* An object that combines the result of a feature flag evaluation with information about
28+
* how it was calculated.
829
*
9-
* @remarks
10-
* We will be deprecating this type in favor of {@link CommonLDEvaluationDetailTyped} in the
11-
* next major version.
30+
* This is the result of calling detailed variation methods.
1231
*/
13-
export type LDEvaluationDetailTyped<TFlag> = Omit<CommonLDEvaluationDetailTyped<TFlag>, 'reason'> & {
32+
export type LDEvaluationDetailTyped<TFlag> = Omit<CommonDetailTyped<TFlag>, 'reason'> & {
1433
/**
1534
* An optional object describing the main factor that influenced the flag evaluation value.
1635
*/

packages/sdk/react-native/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export * from './LDPlugin';
1616

1717
// Override the common type with a client specific one.
1818
// TODO: we will remove this once we major version this SDK.
19-
export type { LDEvaluationDetailTyped } from './hooks/variation/LDEvaluationDetail';
19+
export type { LDEvaluationDetailTyped, LDEvaluationDetail } from './hooks/variation/LDEvaluationDetail';
20+
2021
export { ReactNativeLDClient, RNOptions as LDOptions, RNStorage };

0 commit comments

Comments
 (0)