siimon / prom-client

Prometheus client for node.js
Apache License 2.0
3.15k stars 376 forks source link

Histogram startTimer return value in typescript definition incorrect? #617

Open kevkcc opened 8 months ago

kevkcc commented 8 months ago

Hi,

I was wondering if the following line should return number instead of void.

https://github.com/siimon/prom-client/blob/a88a5c3ce4e928ff05d91e64e74376495bfe0570/index.d.ts#L566

I wanted to start a timer on a specific label and am doing something like this in my code:

const end = histogram.labels({ mylabels }).startTimer();
// some stuff
const seconds = end();

But I was surprised to see that this startTimer in the ts definitions doesn't return number and supposedly returns void. In testing, my code works and it still returns a number so I believe it's just a problem with the ts definition.

a1300 commented 4 weeks ago

Looks like this has been fixed in index.d.ts:

https://github.com/siimon/prom-client/blob/c1d76c5d497ef803f6bd90c56c713c3fa811c3e0/index.d.ts#L504-L511

@siimon this issue can be closed