Skip to content

Commit

Permalink
fix EvaluationDetail.reason to be nullable so we can get rid of NonNu…
Browse files Browse the repository at this point in the history
…llableLDEvaluationReason 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
  • Loading branch information
eli-darkly authored Jan 15, 2022
1 parent c26d831 commit cf9ec23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var jsonFlagValue: ld.LDFlagValue = client.variation('key', [ 'a', 'b' ]);
var detail: ld.LDEvaluationDetail = client.variationDetail('key', 'default');
var detailValue: ld.LDFlagValue = detail.value;
var detailIndex: number | undefined = detail.variationIndex;
var detailReason: ld.LDEvaluationReason = detail.reason;
var detailReason: ld.LDEvaluationReason | undefined = detail.reason;

client.setStreaming(true);
client.setStreaming();
Expand Down
18 changes: 4 additions & 14 deletions typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,8 @@ declare module 'launchdarkly-js-sdk-common' {
/**
* Describes the reason that a flag evaluation produced a particular value. This is
* part of the [[LDEvaluationDetail]] object returned by [[LDClient.variationDetail]].
*
* This type is separate from `[[LDEvaluationReason]]` for backwards compatibility. In
* earlier versions of this SDK, `[[LDEvaluationReason]]` was incorrectly defined as
* being non-nullable.
*/
interface NonNullableLDEvaluationReason {
interface LDEvaluationReason {
/**
* The general category of the reason:
*
Expand Down Expand Up @@ -392,14 +388,6 @@ declare module 'launchdarkly-js-sdk-common' {
prerequisiteKey?: string;
}

/**
* Describes the reason that a flag evaluation produced a particular value. This is
* part of the [[LDEvaluationDetail]] object returned by [[LDClient.variationDetail]].
*
* Will be null when `[[LDOptions.evaluationReasons]]` is `false`.
*/
export type LDEvaluationReason = NonNullableLDEvaluationReason | null;

/**
* An object that combines the result of a feature flag evaluation with information about
* how it was calculated.
Expand All @@ -423,8 +411,10 @@ declare module 'launchdarkly-js-sdk-common' {

/**
* An object describing the main factor that influenced the flag evaluation value.
* This will be `null`/`undefined` if the SDK was not configured to get evaluation
* reasons.
*/
reason: LDEvaluationReason;
reason?: LDEvaluationReason;
}

/**
Expand Down

0 comments on commit cf9ec23

Please sign in to comment.