optimizely/javascript-sdk

[BUG] Missing types for notificationCenter.addNotificationListener

rupesh-checkatrade opened this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues

SDK Version

5.3.4

Current Behavior

There are no types exported for the 'decisionPayload' that comes back from an notificationCenter.addNotificationListener

Expected Behavior

Precise types should be exported for the object returned to the callback

Steps To Reproduce

  1. setup the SDK in an TypeScript project
  2. add a notificationCenter.addNotificationListener
  3. try to set/infer the type of the parameters in the callback

SDK Type

Browser

Node Version

No response

Browsers impacted

No response

Link

No response

Logs

No response

Severity

No response

Workaround/Solution

No response

Recent Change

No response

Conflicts

No response

I've had to construct my own using a selection of other exported types:

interface OptimizelyDecisionInfo
  extends Omit<OptimizelyDecision, 'userContext' | 'reasons'> {
  decisionEventDispatched: boolean;
}

interface OptimizelyDecisionCallbackPayload extends ListenerPayload {
  type: string; // declared enum in but not exposed from @optimizely/optimizely-sdk/dist/utils/enums/index.d.ts
  decisionInfo: OptimizelyDecisionInfo;
}