Skip to content

fix: avoid ambient type leaks in declarations - #660

Closed
michalius wants to merge 2 commits into
tinylibs:mainfrom
michalius:fix/ambient-type-leaks
Closed

michalius wants to merge 2 commits into
tinylibs:mainfrom
michalius:fix/ambient-type-leaks

Conversation

@michalius

Copy link
Copy Markdown
Contributor

Fixes #658.

The generated declarations currently leak two ambient types from Tinybench's build environment:

  • BenchEvent extends globalThis.Event
  • performanceNow is inferred as returning DOMHighResTimeStamp

These declarations fail for consumers that intentionally don't include lib.dom, including the Workerd reproduction from #658 and strict Node-only consumers.

This change:

  • uses Event directly for BenchEvent
  • explicitly types performanceNow as the existing NowFn (() => number)

The runtime behavior is unchanged; the changes only prevent environment-specific ambient types from leaking into the published declarations.

@michalius

Copy link
Copy Markdown
Contributor Author

I noticed #659 was opened shortly before this PR and addresses the same issue more comprehensively, including declaration regression coverage. Closing this one in favor of #659.

Thanks. Glad to have independently confirmed the NowFn fix and the Node/Vitest 5 reproduction in #658.

@michalius michalius closed this Sep 5, 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.

tinybench@6.1.5 declarations require globalThis.Event and DOMHighResTimeStamp with Wrangler-generated Workerd types

1 participant