gdaws / stompit

STOMP client library for node.js
MIT License
162 stars 36 forks source link

Typings #80

Open Sacro opened 6 years ago

Sacro commented 6 years ago

I would love to use this library with Typescript rather than Javascript, are there any typings available?

DanielRose commented 5 years ago

I created type definitions: https://github.com/DanielRose/DefinitelyTyped/tree/stompit

If no-one complains, I'll send a PR to DefinitelyTyped.

afurculita commented 5 years ago

@DanielRose how about submitting a PR here too? I think a better place for TS typings is the original repo.

DanielRose commented 5 years ago

@gdaws It is up to the maintainer what would be preferred. The type definitions could be bundled with the package as well.

DanielRose commented 5 years ago

The type definitions were merged and can now be found in https://www.npmjs.com/package/@types/stompit

hazzo commented 4 years ago

Hi, could be that the merged types are now obsolete?

For example, in the type connect.connectOptions the host property only exists inside connectHeaders and not also in the parent object as the actual JavaScript documentation shows.

Thanks!

DanielRose commented 4 years ago

@hazzo The type connect.ConnectOptions is defined as:

type ConnectOptions = NetTcpConnectOptions | NetIpcConnectOptions | SslConnectOptions;

Their types define a host property (among others):

interface NetTcpConnectOptions extends BaseConnectOptions, TcpNetConnectOpts {
    ssl?: false;
}
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
    timeout?: number;
}
interface TcpSocketConnectOpts extends ConnectOpts {
    port: number;
    host?: string;
    localAddress?: string;
    localPort?: number;
    hints?: number;
    family?: number;
    lookup?: LookupFunction;
}

And so on. However, an IPC connection does not have a host (since it always is the same system). So to see the correct options, you'll probably have to cast/declare your options objects with the correct type.

hazzo commented 4 years ago

@DanielRose thanks! I missed completely the extended interfaces!!! T_T