Description
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!