prom-client icon indicating copy to clipboard operation
prom-client copied to clipboard

hashMap prop not typed in index.d.ts

Open guyellis opened this issue 4 years ago • 1 comments

The hashMap property is not typed in the index.d.ts file. Is this because it's considered private and shouldn't be accessed?

My use case is to access this in the tests that I'm writing (in Typescript) and check for certain values. I could of course @ts-ignore but I obviously don't want to do that. If the shape changes in the future and it's not typed then I won't get any tsc transpile errors.

guyellis avatar Mar 27 '20 13:03 guyellis

I guess in my tests I can:

  interface HistogramWithHashMap<T extends string> extends Histogram<T> {
    hashMap: object; // etc.
  }

and in the test

    const metric = getSingleMetric(
      'foo',
    ) as HistogramWithHashMap<string>;

However, would still love the type to be in this repo in case the shape changes in a future version. Also a single place to maintain this instead of multiple.

guyellis avatar Mar 27 '20 13:03 guyellis