Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom event to the process emitter

I have this:

enter image description here

The code is like so:

process.emit('domainHavenRejection', 'unhandled rejection could not be pinned to a request/response.', e);

Obviously I am using TypeScript...is there a way to define a custom event on process, with the right type, or should I use a different event emitter?

Note that 'domainHavenRejection' is my desired custom event name, but it could be any custom event, obviously.

like image 697
Alexander Mills Avatar asked May 30 '26 06:05

Alexander Mills


1 Answers

You can make compiler do not check types for emit() method.

(process.emit as Function)('domainHavenRejection');

Seems for now it is not possible to extend NodeJs interface. But take a look at this issue https://github.com/typings/registry/issues/770

like image 134
Vayrex Avatar answered May 31 '26 20:05

Vayrex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!