Skip to content

Commit cf9ec23

Browse files
authored
fix EvaluationDetail.reason to be nullable so we can get rid of NonNullableLDEvaluationReason type (#49)
* remove deprecated options and function * rm references to obsolete function * restore deprecation logic, just leave the data empty * remove samplingInterval from TS test code * fix TS test code again * fix EvaluationDetail.reason to be nullable so we can get rid of NonNullableLDEvaluationReason type * fix TS test code
1 parent c26d831 commit cf9ec23

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

test-types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var jsonFlagValue: ld.LDFlagValue = client.variation('key', [ 'a', 'b' ]);
7676
var detail: ld.LDEvaluationDetail = client.variationDetail('key', 'default');
7777
var detailValue: ld.LDFlagValue = detail.value;
7878
var detailIndex: number | undefined = detail.variationIndex;
79-
var detailReason: ld.LDEvaluationReason = detail.reason;
79+
var detailReason: ld.LDEvaluationReason | undefined = detail.reason;
8080

8181
client.setStreaming(true);
8282
client.setStreaming();

typings.d.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,8 @@ declare module 'launchdarkly-js-sdk-common' {
351351
/**
352352
* Describes the reason that a flag evaluation produced a particular value. This is
353353
* part of the [[LDEvaluationDetail]] object returned by [[LDClient.variationDetail]].
354-
*
355-
* This type is separate from `[[LDEvaluationReason]]` for backwards compatibility. In
356-
* earlier versions of this SDK, `[[LDEvaluationReason]]` was incorrectly defined as
357-
* being non-nullable.
358354
*/
359-
interface NonNullableLDEvaluationReason {
355+
interface LDEvaluationReason {
360356
/**
361357
* The general category of the reason:
362358
*
@@ -392,14 +388,6 @@ declare module 'launchdarkly-js-sdk-common' {
392388
prerequisiteKey?: string;
393389
}
394390

395-
/**
396-
* Describes the reason that a flag evaluation produced a particular value. This is
397-
* part of the [[LDEvaluationDetail]] object returned by [[LDClient.variationDetail]].
398-
*
399-
* Will be null when `[[LDOptions.evaluationReasons]]` is `false`.
400-
*/
401-
export type LDEvaluationReason = NonNullableLDEvaluationReason | null;
402-
403391
/**
404392
* An object that combines the result of a feature flag evaluation with information about
405393
* how it was calculated.
@@ -423,8 +411,10 @@ declare module 'launchdarkly-js-sdk-common' {
423411

424412
/**
425413
* An object describing the main factor that influenced the flag evaluation value.
414+
* This will be `null`/`undefined` if the SDK was not configured to get evaluation
415+
* reasons.
426416
*/
427-
reason: LDEvaluationReason;
417+
reason?: LDEvaluationReason;
428418
}
429419

430420
/**

0 commit comments

Comments
 (0)