Skip to content

Types not importable for notification listeners #121

Closed
@spinndigo

Description

@spinndigo

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions