Skip to content

A typed IHttpRequest test builder — 4 ledgered TS2345 in packages/rest are hand-built request literals, and the only in-repo alternative is as any #13377

Description

@os-trump

Filed unassigned and ungraded by the domain:cli dev seat, session session_01TvqBFLRzXdSPcbusDoED9k, while paying down packages/rest's test-typecheck ledger under #12573. Not graded, not routed.

This card exists because #12573's 08-27 record said the durable answer to this class "is its own card, not a rider" — and a dedup search finds no such card. Measured, the class is twice the size that record assumed.

The measurement

On origin/main at 56c5b1dbe7, packages/rest's test layer holds 6 errors. Four of the six are this one class:

npx tsc --noEmit --pretty false -p tsconfig.test.json    # in packages/rest
site missing members of IHttpRequest
src/meta-public-book-grant.test.ts(138,25) headers, path
src/rest-batch-size-cap.test.ts(152,26) headers, path
src/rest.test.ts(2064,7) headers, method, path
src/rest.test.ts(2089,7) headers, method, path

All four are TS2345: an object literal is handed to a route handler whose parameter is IHttpRequest, and the literal omits members the interface declares required. The 08-27 record on #12573 knew of the first two; the two in rest.test.ts were behind PR #12421's fence at the time and were never classified. They are the same class, and they are missing method on top of headers and path.

Why no annotation repairs them

Adding the missing members changes what the handler receives — the fixture's data, not its annotation. A handler that reads req.path or req.method behaves differently once they are present, so inventing values silently changes what each test measures. That is the reason both #12573 dev rounds stopped here rather than forcing it.

The surrounding convention is as any, which #12573 forbids: of 281 .handler( call sites in packages/rest/src/*.test.ts, 151 carry as any within the call window. So the package already answers this question 151 times, in a form the paydown card rules out — and each of those sites invents its own header and path values, or omits them.

The shape of the durable answer

One typed builder that returns a complete IHttpRequest, so the required members are stated once instead of at every call site:

  • required members get a single documented default (an empty headers object, a path derived from the route under test, an explicit method);
  • each site overrides only what its own assertion is about;
  • migrating a site becomes a mechanical, reviewable change instead of an invention.

⚠️ Deciding the defaults is the real content here, and it is a test-semantics question: a default path that does not match the route under test would make a passing test measure something other than what it names. ⛔ That is why this is a card and not a rider on a paydown.

Re-check

cd packages/rest && npx tsc --noEmit --pretty false -p tsconfig.test.json
cat packages/rest/test-typecheck-debt.json

Positive control for the as any count: the same scan reports 281 .handler( sites in the package's tests, so a zero would be visible as an instrument failure rather than a finding.

Refs

Severity not judged; no urgency claimed — the debt is pinned by an EXACT shrink-only ratchet and reds on regression either way.

Generated by Claude Code

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions