Skip to content

test: type check the test tree and fix fixture drift - #959

Merged
robwoodgate merged 1 commit into
v4-devfrom
test/v4-typecheck-gate
Aug 12, 2026
Merged

test: type check the test tree and fix fixture drift#959
robwoodgate merged 1 commit into
v4-devfrom
test/v4-typecheck-gate

Conversation

@robwoodgate

Copy link
Copy Markdown
Collaborator

Description

Backport of the type-check gate added on main in #954. Nothing has ever run tsc over test/ on this line either: vitest strips types via esbuild without checking them, and test/tsconfig.json existed only to give eslint's typed rules a project covering the test tree, which catches rule violations rather than assignability. src/ was covered all along, indirectly, since api:check runs vite-plugin-dts.

v4 had drifted far less than main did: 21 errors across 10 files, against main's 89 across 12. With v4 remaining the GA line until v5 ships, that seemed worth closing.

Changes

  • npm run check-types runs tsc -p test/tsconfig.json. The tests import the library source directly rather than the built package, so tsc follows those imports and pulls all 81 files in src/ into the same program. One command therefore covers both trees. test/tsconfig.json gained rootDir and noEmit so a bare tsc -p behaves the same on the command line as it already did in an editor.
  • Wired into prtasks, a types.yml workflow following this branch's existing lint.yml shape (including its actions/*@v4 pins), and the pre-push hook.
  • test/consumer/ is excluded. Those harnesses deliberately import the package by its published name to simulate an external consumer, so they only resolve after a build. They are covered by consumers.yml, which builds first, and eslint skips them for the same reason.
  • Fixtures realigned with the current types. The bulk is Logger gaining a log method after the mock helpers were written. The rest: MintQuoteBolt12Response has no state and MintQuoteOnchainResponse no amount (both use the accounting fields), an optional pubkey needing an assertion, and two stale arguments left over from older signatures, including an idempotent request option that exists nowhere in src/.
  • AGENTS.md and CONTRIBUTING.md updated for the new command.

Reviewer Notes

  • No files under src/ are touched and etc/cashu-ts.api.md is unchanged, so there is no public API movement.
  • Fixes deliberately mirror the shapes used on main so that future backports apply cleanly. The only divergence is prettier line wrapping where adding log: vi.fn() crossed the print width.
  • Verified with lib/ moved aside, to simulate a clean checkout: that is exactly the case that slipped through locally on main and failed CI there, because a previous build had made test/consumer/ resolve.
  • npm run prtasks passes end to end: 179 test files, 6097 tests.

Backport of the gate added on main in #954. Vitest strips types without
checking them, and test/tsconfig.json only fed eslint's typed rules, so nothing
ever ran tsc over test/. src/ was already covered indirectly via api:check.
21 fixtures had drifted from the library types.

- add check-types (tsc over test/, which pulls src/ in through its imports),
  wired into prtasks, a types.yml workflow and the pre-push hook
- exclude the consumer harnesses: they import the built package by its
  published name, so they only resolve after a build, and eslint skips them
  for the same reason
- realign the drifted fixtures, chiefly Logger gaining log, bolt12 mint quotes
  having no state and onchain quotes no amount, plus two stale arguments
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v4-dev@34e2861). Learn more about missing BASE report.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##             v4-dev     #959   +/-   ##
=========================================
  Coverage          ?   95.48%           
=========================================
  Files             ?       49           
  Lines             ?     5162           
  Branches          ?     1290           
=========================================
  Hits              ?     4929           
  Misses            ?      100           
  Partials          ?      133           
Flag Coverage Δ
integration 39.07% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@robwoodgate
robwoodgate merged commit 9a3a0f4 into v4-dev Aug 12, 2026
19 checks passed
@robwoodgate
robwoodgate deleted the test/v4-typecheck-gate branch August 12, 2026 19:38
@github-project-automation github-project-automation Bot moved this from Backlog to Done in cashu-ts Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant