Skip to content

Problem in .d.ts definition, -> logical errors when using typescript code #652

@haeferer

Description

@haeferer

First, thx for your great work.

The last 3 hours i was looking for a problem. My pushgateway instance seems to have no connection to the registry.

Since the TS Compiler does not show an error, i've not checked to code ...

let push = new Pushgateway('http://127.0.0.1:9091', reg);

This code is TS correct, but wrong.

Reason:
The Typedefintion

constructor(url: string, options?: any, registry?: Registry<T>);

options is typed as any and registry as optional.

So it is correct to forget the option parameter, so the registry parameter ist used as "option"

Which does not make any sence. I created a Pushgateways without a connected registry ...

Solution:

If i look into the source code the type is Url from packege "url" extended with a single property requireJobName: true, ?

So a better type for option is {requireJobName: boolean}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions