Skip to content

Add getMetricsAsString to TypeScript definitions#768

Open
bugprone wants to merge 2 commits into
prometheus:mainfrom
bugprone:fix-registry-get-metrics-as-string-type
Open

Add getMetricsAsString to TypeScript definitions#768
bugprone wants to merge 2 commits into
prometheus:mainfrom
bugprone:fix-registry-get-metrics-as-string-type

Conversation

@bugprone

@bugprone bugprone commented Jul 7, 2026

Copy link
Copy Markdown

Purpose

Registry#getMetricsAsString(metric) exists at runtime, but it is missing from the TypeScript declarations. This makes the method unavailable to TypeScript users even though it is already implemented.

Fixes #678.

Changes

  • Add Registry#getMetricsAsString<T>(metric: Metric<T>): Promise<string> to index.d.ts
  • Add a small TypeScript compile check that calls registry.getMetricsAsString(counter)
  • Update the unreleased changelog

Testing

  • npm test -- --runInBand --forceExit

bugprone added 2 commits July 6, 2026 17:25
Signed-off-by: Jace <bugprone@gmail.com>
Signed-off-by: Jace <bugprone@gmail.com>
@bugprone bugprone force-pushed the fix-registry-get-metrics-as-string-type branch from d7747fe to 4f50b4f Compare July 7, 2026 00:26
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

Successfully merging this pull request may close these issues.

Why getMetricAsString doesn't exist in types declaration?

2 participants