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

Typings #80

Open
Sacro opened this issue Apr 19, 2018 · 7 comments
Open

Typings #80

Sacro opened this issue Apr 19, 2018 · 7 comments

Comments

@Sacro
Copy link

Sacro commented Apr 19, 2018

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

@DanielRose
Copy link

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

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

@afurculita
Copy link

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

@DanielRose
Copy link

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

@DanielRose
Copy link

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

@hazzo
Copy link

hazzo commented Jan 20, 2020

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
Copy link

@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
Copy link

hazzo commented Jan 28, 2020

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

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

4 participants