openclaw - ✅(Solved) Fix [Bug]: pnpm check fails on main due to TypeScript errors in extensions/openrouter [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#60884Fetched 2026-04-08 02:46:09
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
labeled ×2closed ×1commented ×1cross-referenced ×1

A fresh clone of openclaw/openclaw on main fails the repo check gate because pnpm check reports TypeScript errors in extensions/openrouter.

Error Message

extensions/openrouter/index.test.ts(46,41): error TS2493: Tuple type '[]' of length '0' has no element at index '0'. extensions/openrouter/index.ts(94,7): error TS2322: Type 'StreamFn | null | undefined' is not assignable to type 'StreamFn | undefined'. extensions/openrouter/index.test.ts(46,41): error TS2493: Tuple type '[]' of length '0' has no element at index '0'. extensions/openrouter/index.ts(94,7): error TS2322: Type 'StreamFn | null | undefined' is not assignable to type 'StreamFn | undefined'.

Root Cause

A fresh clone of openclaw/openclaw on main fails the repo check gate because pnpm check reports TypeScript errors in extensions/openrouter.

Fix Action

Fixed

PR fix notes

PR #60900: fix(openrouter): remove redundant null coercion in stream wrapper

Description (problem / solution / changelog)

Summary

  • Remove redundant ?? undefined coercions in wrapOpenRouterProviderStream
    • Line 94: OPENROUTER_THINKING_STREAM_HOOKS.wrapStreamFn ?? undefined was a no-op (property is already undefined when absent)
    • Lines 98-103: wrapStreamFn({...}) ?? undefined was dead code since fb59b5c widened the return type to StreamFn | null | undefined

Closes #60884

Root cause

a6707c2 (refactor(providers): flatten shared stream hooks) introduced two tsgo type errors in extensions/openrouter/:

FileLineError
index.test.ts46:41TS2493: Tuple type [] has no element at index 0mock.calls[0] on untyped vi.fn()
index.ts94:7TS2322: StreamFn | null | undefined not assignable to StreamFn | undefined

These were addressed by 9cc300b and fb59b5c (direct pushes to main), but left behind two no-op ?? undefined expressions. This PR removes them.

Test plan

  • pnpm check passes (tsgo + oxlint + all policy checks)
  • tsc --noEmit passes
  • Grepped extensions/ for similar ?? undefined no-op patterns — none found

🤖 Generated with Claude Code

Changed files

  • extensions/openrouter/index.ts (modified, +5/-7)

Code Example

$ pnpm install --frozen-lockfile
Done in 14.3s using pnpm v10.32.1

$ pnpm check

> openclaw@2026.4.4 check /private/tmp/openclaw-gitbug
> pnpm check:no-conflict-markers && pnpm check:host-env-policy:swift && pnpm tsgo && pnpm lint && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope

> openclaw@2026.4.4 check:no-conflict-markers /private/tmp/openclaw-gitbug
> node scripts/check-no-conflict-markers.mjs

> openclaw@2026.4.4 check:host-env-policy:swift /private/tmp/openclaw-gitbug
> node scripts/generate-host-env-security-policy-swift.mjs --check

OK apps/macos/Sources/OpenClaw/HostEnvSecurityPolicy.generated.swift

> openclaw@2026.4.4 tsgo /private/tmp/openclaw-gitbug
> node scripts/run-tsgo.mjs

extensions/openrouter/index.test.ts(46,41): error TS2493: Tuple type '[]' of length '0' has no element at index '0'.
extensions/openrouter/index.ts(94,7): error TS2322: Type 'StreamFn | null | undefined' is not assignable to type 'StreamFn | undefined'.
  Type 'null' is not assignable to type 'StreamFn | undefined'.
ELIFECYCLECommand failed with exit code 2.
ELIFECYCLECommand failed with exit code 2.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

A fresh clone of openclaw/openclaw on main fails the repo check gate because pnpm check reports TypeScript errors in extensions/openrouter.

Steps to reproduce

  1. Clone the repository: git clone https://github.com/openclaw/openclaw.git
  2. Enter the repo: cd openclaw
  3. Install dependencies: pnpm install --frozen-lockfile
  4. Run: pnpm check
  5. Observe TypeScript failures in extensions/openrouter/index.ts and extensions/openrouter/index.test.ts

Expected behavior

pnpm check should pass on main in a fresh clone after a successful pnpm install --frozen-lockfile.

Actual behavior

pnpm check fails during the TypeScript check step with these observed errors:

extensions/openrouter/index.test.ts(46,41): error TS2493: Tuple type '[]' of length '0' has no element at index '0'. extensions/openrouter/index.ts(94,7): error TS2322: Type 'StreamFn | null | undefined' is not assignable to type 'StreamFn | undefined'. Type 'null' is not assignable to type 'StreamFn | undefined'.

OpenClaw version

2026.4.4

Operating system

Darwin 25.4.0 (arm64)

Install method

pnpm from source

Model

Not applicable

Provider / routing chain

Not applicable

Additional provider/model setup details

Not applicable; the failure occurs in repo TypeScript checks before runtime model/provider execution.

Logs, screenshots, and evidence

$ pnpm install --frozen-lockfile
Done in 14.3s using pnpm v10.32.1

$ pnpm check

> [email protected] check /private/tmp/openclaw-gitbug
> pnpm check:no-conflict-markers && pnpm check:host-env-policy:swift && pnpm tsgo && pnpm lint && pnpm lint:webhook:no-low-level-body-read && pnpm lint:auth:no-pairing-store-group && pnpm lint:auth:pairing-account-scope

> [email protected] check:no-conflict-markers /private/tmp/openclaw-gitbug
> node scripts/check-no-conflict-markers.mjs

> [email protected] check:host-env-policy:swift /private/tmp/openclaw-gitbug
> node scripts/generate-host-env-security-policy-swift.mjs --check

OK apps/macos/Sources/OpenClaw/HostEnvSecurityPolicy.generated.swift

> [email protected] tsgo /private/tmp/openclaw-gitbug
> node scripts/run-tsgo.mjs

extensions/openrouter/index.test.ts(46,41): error TS2493: Tuple type '[]' of length '0' has no element at index '0'.
extensions/openrouter/index.ts(94,7): error TS2322: Type 'StreamFn | null | undefined' is not assignable to type 'StreamFn | undefined'.
  Type 'null' is not assignable to type 'StreamFn | undefined'.
 ELIFECYCLE  Command failed with exit code 2.
 ELIFECYCLE  Command failed with exit code 2.

Impact and severity

Affected users/systems/channels: Contributors working from a fresh clone of openclaw/openclaw on main Severity: High (blocks the repo check workflow) Frequency: Observed on the reproduced run above Consequence: Contributors cannot complete pnpm check successfully on main

Additional information

This appears isolated to extensions/openrouter based on the observed TypeScript failures.

The related test file still passes when run directly under the broader Vitest config:

  • src/channels/targets.test.ts passed
  • src/channels/plugins/message-actions.security.test.ts passed
  • extensions/openrouter/index.test.ts passed

So the issue appears to be with the repo TypeScript check path rather than the runtime test behavior itself.

extent analysis

TL;DR

Update the TypeScript configuration or code in extensions/openrouter to resolve the reported type errors.

Guidance

  1. Review TypeScript version and configuration: Ensure that the TypeScript version used in the project is compatible with the code in extensions/openrouter. Check the tsconfig.json file for any settings that might be causing the errors.
  2. Fix type errors in extensions/openrouter: Address the specific type errors reported, such as the tuple type error in index.test.ts and the type assignment error in index.ts. This may involve updating type definitions or adjusting the code to match the expected types.
  3. Verify TypeScript checks: After making changes, re-run pnpm check to ensure that the TypeScript errors are resolved and the check passes.
  4. Check for potential null or undefined values: In index.ts, the error message suggests that null is not assignable to StreamFn | undefined. Review the code to ensure that null values are properly handled or excluded from the type.

Example

No specific code example is provided due to the lack of detailed code context, but the fix will likely involve updating type annotations or adjusting the code in extensions/openrouter/index.ts and extensions/openrouter/index.test.ts to resolve the reported type errors.

Notes

The issue seems isolated to the TypeScript check path and not related to the runtime behavior of the tests, which pass when run directly. This suggests that the problem is with the TypeScript configuration or the code in extensions/openrouter rather than with the tests themselves.

Recommendation

Apply a workaround by updating the TypeScript configuration or code in extensions/openrouter to resolve the type errors, as the issue blocks the repo check workflow and has a high severity impact on contributors working from a fresh clone of the repository.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

pnpm check should pass on main in a fresh clone after a successful pnpm install --frozen-lockfile.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING