Skip to content

[Bug]: tsc check failing on main — vitest spy type inference (TS2742) #16512

@xinhuagu

Description

@xinhuagu

Summary

The check job (tsc type checking) is consistently failing on main due to vitest spy type inference errors.

Error

error TS2742: The inferred type of 'mockLoadConfig' cannot be named without a reference to
'.pnpm/@[email protected]/node_modules/@vitest/spy'. This is likely not portable.
A type annotation is necessary.

Affected files

  • src/web/monitor-inbox.test-harness.ts
  • src/auto-reply/reply.triggers.trigger-handling.test-harness.ts
  • src/auto-reply/reply/agent-runner.heartbeat-typing.test-harness.ts
  • src/auto-reply/reply/agent-runner.memory-flush.test-harness.ts

Evidence

Likely cause

vi.fn() return values in test-harness files lack explicit type annotations. When tsc emits declaration files, it cannot resolve the inferred Mock<...> type without a direct reference to @vitest/spy.

Suggested fix

Add explicit type annotations to the mock variables in test-harness files, e.g.:

import type { Mock } from 'vitest';
const mockLoadConfig: Mock<(...args: any[]) => any> = vi.fn();

Or adjust the tsconfig to skip declaration emit for test files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions