Skip to content

fix: use the same signature when implementing BenchLike#541

Merged
jerome-benoit merged 1 commit into
mainfrom
fix/use-optional-signature
Apr 27, 2026
Merged

fix: use the same signature when implementing BenchLike#541
jerome-benoit merged 1 commit into
mainfrom
fix/use-optional-signature

Conversation

@sheremet-va

Copy link
Copy Markdown
Member

When using exactOptionalPropertyTypes, it's not valid to define val: Value | undefined when implementing val?: Value interface:

https://github.com/vitest-dev/vitest/actions/runs/24994604053/job/73188302056?pr=10113

  Error: ../../../../node_modules/.pnpm/tinybench@6.0.0/node_modules/tinybench/dist/index.d.ts(629,15): error TS2420: Class 'Bench' incorrectly implements interface 'BenchLike'.
    Types of property 'signal' are incompatible.
      Type 'AbortSignal | undefined' is not assignable to type 'AbortSignal'.
        Type 'undefined' is not assignable to type 'AbortSignal'.

Copilot AI review requested due to automatic review settings April 27, 2026 12:39
@pkg-pr-new

pkg-pr-new Bot commented Apr 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/tinybench@541

commit: 3f8964e

@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
dist/index.js 10.14 KB (0%) 203 ms (0%) 5 ms (-18.35% 🔽) 208 ms

@sheremet-va sheremet-va changed the title fix: use the same signature when implementing BenchLike fix: use the same signature when implementing BenchLike Apr 27, 2026

Copilot AI 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.

Pull request overview

Updates Bench’s signal property declaration to match the BenchLike interface under exactOptionalPropertyTypes, avoiding invalid “optional vs | undefined” signature mismatches for downstream consumers (e.g., Vitest builds with that compiler option enabled).

Changes:

  • Change Bench.signal from AbortSignal | undefined to an optional property signal?: AbortSignal to correctly implement BenchLike.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jerome-benoit jerome-benoit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@jerome-benoit jerome-benoit added this pull request to the merge queue Apr 27, 2026
Merged via the queue into main with commit 5a12342 Apr 27, 2026
38 checks passed
@jerome-benoit jerome-benoit deleted the fix/use-optional-signature branch April 27, 2026 16:19
@jerome-benoit

Copy link
Copy Markdown
Collaborator

@sheremet-va: I will do a patch release with that API fix ASAP.

@sheremet-va

Copy link
Copy Markdown
Member Author

@sheremet-va: I will do a patch release with that API fix ASAP.

Thank you

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.

3 participants