`typecheck` fails on `main` since ac8e1c43: `Property 'compare' does not exist on type 'TestAPI'` in both benchmark files
Summary
The typecheck job is failing on main and has been since ac8e1c43 (chore: migrate changes, 2026-09-11). It is currently the only red job — lint and all six test jobs pass on that commit (run 34553558197, job 103121289529).
bench/bundle-test/bundle.bench.ts(27,12): error TS2339: Property 'compare' does not exist on type 'TestAPI'.
bench/engines/engines.bench.ts(45,14): error TS2339: Property 'compare' does not exist on type 'TestAPI'.Both errors are reproducible locally from a clean main checkout with pnpm typecheck (exit code 2).
Root cause
Vitest 5 moved compare off the test callback context and onto the benchmark context. The Vitest 5 type definitions document it on bench:
it('bundle', async ({ bench }) => {
const result = await bench.compare(bench('a', fn), bench('b', fn))
})Both benchmark files still call compare on the test context, which is why TestAPI has no compare property:
bench/bundle-test/bundle.bench.ts:27—await it.compare(bench/engines/engines.bench.ts:45—await it.compare(
The fix is a one-line change in each file:
it('bundle', async ({ bench }) => {
- await it.compare(
+ await bench.compare(Why the change also needs an ESLint exemption
test/consistent-test-it does not recognize the bench.<member> form yet. Its escape hatch only matches the bare identifier form:
// src/rules/consistent-test-it.ts
if (
node.callee.type === AST_NODE_TYPES.Identifier
&& node.callee.name === 'bench'
)
returnFor bench.compare(...) the callee is a MemberExpression, so the guard does not apply. The rule then reports the bench object and its autofix rewrites it back to it:
45:11 error Prefer using it instead of test test/consistent-test-it
# autofix output, i.e. back to the broken receiver
await it.compare(So lint and typecheck currently contradict each other for these two files, which is presumably how it.compare survived the Vitest 5 migration.
I hit this while preparing the fix: npx eslint --fix on the corrected files silently reverted them. The two benchmark files therefore need to be exempted from that one rule (following the pattern already used at the top of bench/bundle-test/bundle.bench.ts, which disables ts/ban-ts-comment and antfu/no-import-dist), with a comment at the call site explaining why. The exemption can be dropped once the rule learns about the member form — there is related upstream work in flight at vitest-dev/eslint-plugin-vitest#965.
Verification
Before (main):
$ npx vue-tsc --noEmit
bench/bundle-test/bundle.bench.ts(27,12): error TS2339: Property 'compare' does not exist on type 'TestAPI'.
bench/engines/engines.bench.ts(45,14): error TS2339: Property 'compare' does not exist on type 'TestAPI'.
$ echo $?
2After:
$ npx vue-tsc --noEmit
$ echo $?
0
$ npx eslint bench/engines/engines.bench.ts bench/bundle-test/bundle.bench.ts
# clean
$ npx eslint --fix bench/engines/engines.bench.ts bench/bundle-test/bundle.bench.ts
# no further changes (idempotent)No other files are affected; eslint . is only noisy locally on packages/vitepress-twoslash/style.css, which is a gitignored build artifact.
Ready patch
The change is committed and pushed on my fork, if that is useful:
- branch:
EvanProgramming:fix/bench-compare-api - commit:
87694707— fix: callcompareon the benchmark context - diff: 2 files changed, 10 insertions(+), 2 deletions(-)
I was going to open a pull request for it, but GitHub is currently rejecting PR creation from my account against this repository (CreatePullRequest → does not have the correct permissions, and the REST endpoint returns 404 even for deliberately invalid payloads, while issue creation works). I'm happy to open the PR as soon as that clears, or a maintainer can just take the branch/commit directly.
Source: shikijs/shiki