nodejs-mobile / nodejs-mobile-react-native

Node.js for Mobile Apps React Native plugin
https://nodejs-mobile.github.io
MIT License
174 stars 42 forks source link

Incomplete type definitions based on documentation? #3

Open achou11 opened 2 years ago

achou11 commented 2 years ago

According to the documentation here:

In the React Native layer:

The nodejs.channel object inherits from React Native's EventEmitter class, with emit removed and post and send added.

In the Node layer:

The rn_bridge.channel object inherits from Node's EventEmitter class, with emit removed and post and send added.

I'm assuming these statements are still true. If they are, then the type defs in index.d.ts are a little incomplete based on my understanding of how this plugin works. A notable example is addListener on the React Native layer, which – in React Native 0.66.3 – should return a React Native EventSubscription. At the moment, it's typed as:

addListener: (event: string, callback: ChannelCallback, context?: any) => void;

but the return type should instead be the subscription.