Skip to content

fix(tests): restore the tests typecheck gate - #239

Open
xodapi wants to merge 1 commit into
mainfrom
fix/typecheck-tests-gate
Open

fix(tests): restore the tests typecheck gate#239
xodapi wants to merge 1 commit into
mainfrom
fix/typecheck-tests-gate

Conversation

@xodapi

@xodapi xodapi commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Restores pnpm typecheck:tests, which failed with 11 errors across 5 files and therefore validated nothing.

Errors fixed

analyze-session-contract-parity.test.tsimport { readFileSync } was duplicated on two consecutive lines (TS2300 x2). Removed the duplicate.

auth-modal.test.tsxvi.fn(() => "blob:...") declared no parameters, so mock.calls[0] was typed as an empty tuple []. Destructuring const [blob] gave TS2493, and the three blob as Blob casts each gave TS2352 because the source type was undefined. Typed the mock as vi.fn((_blob: Blob) => ...), which matches the real createObjectURL signature and makes the three casts unnecessary.

migration-baseline-state.test.ts and production-db-governance.test.ts — both import untyped .mjs scripts (TS7016 x3), which also made enumlabel implicitly any (TS7006). Added scripts/migration-baseline-state.d.mts and scripts/production-db-change-gate.d.mts, written against the current implementations. runbookId and reviewUrl are declared optional because the test exercises the fail-closed path by calling the gate with paths alone.

rust-analytics-sidecar.test.tstoMatchObject<RustAnalyticsSidecarError>({ code }) passed a type argument to a method that accepts none (TS2558). Removed it, and typed the cases array code field as RustAnalyticsSidecarError["code"] instead of string. That keeps the import in use and makes the four error-code literals checked rather than accepted as arbitrary strings.

Notes

The two .d.mts files describe existing JavaScript; they add no runtime behaviour. Both declarations were written from the implementations rather than inferred, so a declaration cannot silently drift from what the scripts return.

Verification

  • pnpm typecheck:tests — exits 0. Previously exited 2 with 11 errors.
  • pnpm lint — clean.
  • pnpm test on all 5 affected files — 32/32 pass, confirming the declarations match runtime and did not merely satisfy the compiler.

pnpm knip still fails, on tailwind-merge, tailwindcss and knip.config.js hints. Those are pre-existing and outside this diff, which touches neither package.json nor knip.config.js.

Full pnpm test and pnpm test:e2e were not run locally; only the affected files. No production or server access. No real user data, secrets, tokens, raw Brain ID, or private telemetry added.

`pnpm typecheck:tests` failed with 11 errors, so the gate could not
detect new type regressions in test code.

- analyze-session-contract-parity: drop a duplicated `readFileSync` import.
- auth-modal: declare the `createObjectURL` mock parameter so
  `mock.calls[0]` is a one-element tuple instead of `[]`, which also makes
  the three `as Blob` casts unnecessary.
- rust-analytics-sidecar: `toMatchObject` takes no type argument; type the
  case table with `RustAnalyticsSidecarError['code']` instead, which keeps
  the import meaningful and validates the four error codes.
- Add `.d.mts` declarations for `migration-baseline-state.mjs` and
  `production-db-change-gate.mjs`. Both are imported from typed tests, and
  without declarations every export degraded to `any`, which silently
  disabled type checking across those two suites.

Verification: `pnpm typecheck:tests` exits 0; `pnpm lint` clean; the five
affected suites pass 32/32.
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.

1 participant