fix(types): export MetricObjectWithValues, MetricValue and related types#786
fix(types): export MetricObjectWithValues, MetricValue and related types#786milcho0604 wants to merge 2 commits into
Conversation
`Registry.getMetricsAsJSON()` returns `MetricObjectWithValues<MetricValue<string>>[]`, and the per-metric `get()` methods return `MetricObjectWithValues<...>`, but those types (along with the base `MetricObject` and `MetricValueWithName`) were not exported. Consumers could not name the return type without resorting to `Awaited<ReturnType<...>>` workarounds. Export them, consistent with the ~20 other public types already exported from this declaration file. Signed-off-by: Changhyun Kim <milcho0604@gmail.com>
f0d810c to
bc92c0d
Compare
|
I think some TS unit tests would be great here. |
Signed-off-by: Changhyun Kim <milcho0604@gmail.com>
|
Thanks for taking a look, and good call on wanting test coverage. One honest caveat I ran into while adding it: because TypeScript resolves top-level types in type position even without the What I did add to For context, the real value of the explicit |
Registry.getMetricsAsJSON()returnsMetricObjectWithValues<MetricValue<string>>[], and the per-metricget()methods returnMetricObjectWithValues<...>, but those types — along with the baseMetricObjectandMetricValueWithName— are not exported fromindex.d.ts.As a result, consumers cannot name the return type of these public methods and have to fall back to workarounds like
Awaited<ReturnType<Registry['getMetricsAsJSON']>>.This exports the four types, consistent with the ~20 other public types already exported from the same declaration file. No behavior change, declaration-only.
npm run compile-typescriptpasses.prettier --check index.d.tspasses.import { MetricObjectWithValues, MetricValue } from 'prom-client'and annotate thegetMetricsAsJSON()result.