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

Add emit(value: any) definition for when using raw buffer #6

Closed
houtenbos opened this issue Aug 16, 2023 · 2 comments
Closed

Add emit(value: any) definition for when using raw buffer #6

houtenbos opened this issue Aug 16, 2023 · 2 comments

Comments

@houtenbos
Copy link

Description

When using the rawbuffer option in the client, the emit function should also support the emit(value: any) signature. Currently, the type definition only provides emit(event: string, value?: any): Client;. This causes type errors when trying to use the emit function with only a value argument in TypeScript.

Expected Behavior

The type definition for the emit function should include both:

  1. emit(event: string, value?: any): Client;
  2. emit(value: any): Client;

Steps to Reproduce

  1. Set up a TypeScript project with the node-ipc library.
  2. Configure a client to use the rawbuffer option with the following code:
import RawIPC from 'node-ipc';

const ipc = new RawIPC.IPC();
ipc.config.rawBuffer = true;
ipc.config.encoding = 'hex';

ipc.connectTo('test', () => {
    const message = Buffer.from([0x62]);
    ipc.of['test'].emit(message);
});
  1. Notice the type error when trying to use the emit function with only a value argument.
@RIAEvangelist
Copy link
Owner

@houtenbos How would one go about fixing this? I am guessing there is a typescript definition file somewhere?

@houtenbos
Copy link
Author

houtenbos commented Aug 17, 2023

@RIAEvangelist Yes, it is in the @types/node-ipc package. I thought you would also maintain that one, but I now see that is maintained by other people.

Thanks for your quick reply, and I closed the issue because the problem should be solved elsewhere.

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