Skip to content

node:perf_hooks - incorrect types for createHistogram options #19937

@alii

Description

@alii

tldr: temporary safe(ish) workaround:

declare module 'perf_hooks' {
	interface CreateHistogramOptions {
		/**
		 * The minimum recordable value. Must be an integer value greater than 0.
		 * @default 1
		 */
		lowest?: bigint | number;
		/**
		 * The maximum recordable value. Must be an integer value greater than min.
		 * @default Number.MAX_SAFE_INTEGER
		 */
		highest?: bigint | number;
	}
}

const responseTimeHistogram = createHistogram({
	lowest: 20, // works :D
});

This issue exists here on the Bun repo as reference for those trying to use the createHistogram() api. The options object should accept lowest/highest instead of min/max

The real problem exists in Node's types, so I've opened a PR in @types/node to fix it: DefinitelyTyped/DefinitelyTyped#72876

We can close this issue here once that PR merges

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingnode.jsCompatibility with Node.js APIstypesAn issue with TypeScript types

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions