Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types not importable for notification listeners #121

Closed
spinndigo opened this issue Aug 13, 2021 · 1 comment
Closed

Types not importable for notification listeners #121

spinndigo opened this issue Aug 13, 2021 · 1 comment

Comments

@spinndigo
Copy link

spinndigo commented Aug 13, 2021

Hello,

I wanted to attach a notification listener to my team's client instance so we can create an event and pass along to our analytics provider. Specifically, I wanted to attach an ACTIVATE listener. I'd like to create the callback for this outside the call to addNotificationListener and have it be typed. I see the type that this function is expecting is :

NotificationListener<T extends ListenerPayload> = (notificationData: T) => void;

which comes from @optimizely/optimizely-sdk .

The file containing this type also contains other derived types like: ActivateListenerPayload .
While I can derive the less specific type ListenerPayload like this:

type Callback = Parameters<typeof optimizely.notificationCenter.addNotificationListener>[1];

I wish I could import the type from @optimizely/react-sdk via this package , but the types are not exported here.
Furthermore this is the more generic type and what I truly want to use in this case is ActivateListenerPayload .

Is there a reason the types are not exported for use? Or advise what to do in this case to make my function type safe? Thank you!

zashraf1985 pushed a commit that referenced this issue Feb 22, 2022
…ad` (#150)

### Summary
`ActivateListenerPayload` and `TrackListenerPayload` types were exported from `@optimizely/optimizely-sdk` but were missing in `@optimizely/react-sdk` exports.

### Test Plan
Manually tested thoroughly.
All existing unit tests pass.

### Issues
#121
@Tamara-Barum
Copy link

Commit was merged, closing the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants