Skip to content

fix(types): allow string[] label values#774

Closed
AysajanE wants to merge 1 commit into
prometheus:mainfrom
AysajanE:northset/M-015
Closed

fix(types): allow string[] label values#774
AysajanE wants to merge 1 commit into
prometheus:mainfrom
AysajanE:northset/M-015

Conversation

@AysajanE

Copy link
Copy Markdown

Problem

prom-client accepts an array of strings as a label value at runtime — e.g. .inc({ handler: ['/a', '/b'] }), which renders as handler="/a,/b" — but its TypeScript types reject it: the label-values type only allows string | number, so that call fails to type-check even though it works. Reported in #582.

Change

  • index.d.ts: widen the label-values type to string | number | string[] so array-valued labels type-check.
  • test/typescript.ts: add an array-valued-label usage so tsc proves the type now accepts it.

Checks (Node 22)

  • npm run compile-typescript (tsc --project .) and npm run test-unit — both pass.

Fixes #582


Disclosure: this change was prepared with AI assistance and reviewed by me before submitting.
I ran the check(s) above in a network-isolated container and published a signed, re-runnable
record of that run, verifiable via GitHub artifact attestation:
https://northset-oss.github.io/verification-pilot/. Contributor self-run, not a maintainer verification.

Signed-off-by: Aysajan Eziz <aeziz@northset.ai>

@jdmarshall jdmarshall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a subset of #553 that doesn't really move things forward and there was resistance to landing that one that hasn't really abated.

Just making it work for counter isn't really answering the ticket.

@jdmarshall jdmarshall closed this Jul 13, 2026
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.

types: handler might be string or array of strings

2 participants