fix(ci): resolve TS2742 type error blocking all PRs#17393
Open
miloudbelarebia wants to merge 1 commit intoopenclaw:mainfrom
Open
fix(ci): resolve TS2742 type error blocking all PRs#17393miloudbelarebia wants to merge 1 commit intoopenclaw:mainfrom
miloudbelarebia wants to merge 1 commit intoopenclaw:mainfrom
Conversation
bfc1ccb to
f92900f
Compare
Replace `ReturnType<typeof vi.fn>` with `MockInstance` from vitest. The inferred type referenced a non-portable internal path (.pnpm/@vitest[email protected]/node_modules/@vitest/spy) that TypeScript could not resolve when exporting the function. `MockInstance` is directly exported by vitest and provides the same type contract. This error blocks the `check` job (tsgo) on all pull requests. Closes openclaw#17315 Co-Authored-By: Claude Opus 4.6 <[email protected]>
caad89a to
7dd206a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/slack/monitor/slash.test-harness.tsthat blocks thecheckjob (pnpm tsgo) on all pull requestsReturnType<typeof vi.fn>withMockInstance(directly exported by vitest) to resolve the non-portable type reference to.pnpm/@[email protected]/...Root Cause
The
getSlackSlashMocks()function is exported, so TypeScript needs to generate a portable type definition.ReturnType<typeof vi.fn>resolves to an internal vitest type at a.pnpm/path that TypeScript cannot reference portably, triggering TS2742.MockInstanceis the proper public type exported by vitest for mock functions and provides the exact same type contract.Impact
Critical — This error currently blocks the
checkCI job on every PR in the repository.Closes #17315
Note on #17341 (OOM)
The CI OOM crash (issue #17341) requires adding
NODE_OPTIONS: --max-old-space-size=4096to the Ubuntuchecksjob in.github/workflows/ci.yml. This change needs theworkflowtoken scope and couldn't be included in this PR. The fix is documented in the issue — a maintainer with write access can apply it (2-line change matching the existing Windows/macOS configuration).Local Validation
pnpm check(tsgo): ✅ passes — this is the exact job this PR fixespnpm test: N/A — type-only change, no runtime behavior affectedoxfmt --checkScope
Single-file, single-concern: one type annotation change in
src/slack/monitor/slash.test-harness.ts. No functional or behavioral changes.AI Assistance
AI-assisted (Claude Code) for codebase exploration and drafting. The root cause analysis (identifying TS2742 caused by non-portable
.pnpm/path in exported function return type), the fix approach (replacingReturnType<typeof vi.fn>withMockInstance), and verification are my own work.Testing level: Fully tested — confirmed
pnpm checkpasses locally and CIcheckjob passes.Test plan
checkjob passes (tsgo no longer errors on this file)MockInstanceis the same type asReturnType<typeof vi.fn>Greptile Summary
Fixes a TS2742 type error in
src/slack/monitor/slash.test-harness.tsthat was blocking thecheckCI job (pnpm tsgo) on all PRs. The fix replacesReturnType<typeof vi.fn>with vitest's publicly exportedMockInstancetype in theSlashHarnessMockstype definition.ReturnType<typeof vi.fn>resolved to an internal vitest type at a.pnpm/path that TypeScript cannot reference portably in declaration output, triggering TS2742 on the exportedgetSlackSlashMocks()functionMockInstanceis the correct public API type from vitest for mock function instances, and is already used in other test helpers in this codebase (e.g.,audio.test-helpers.ts)ReturnType<typeof vi.fn>in exported contexts, so this is the only instance of the issueConfidence Score: 5/5
MockInstancetype is already used elsewhere in the codebase, confirming it's an established pattern. No runtime behavior changes, no logic changes, no new dependencies. The root cause analysis is sound (TS2742 from exported function with non-portable return type).Last reviewed commit: caad89a