Repository navigation
chore: tighten typings across the app - #29
Merged
Merged
Conversation
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
…type can catch
Some routes wrap their success body in `{ data }` and some return it bare. The
http client returns the parsed body verbatim, so a method declaring
`Promise<UserProfile>` against a wrapping route actually resolves to
`{ data: UserProfile }`. TypeScript never notices, because the generic is
asserted — `this.get<UserProfile>(...)` — rather than inferred from the wire.
And the msw handlers are written from the declared types, so the suite agrees
with the type while the type disagrees with the API.
That combination has produced three wrong contracts a green suite certified:
Scaffald/sdk#21 (employers), #26 (organizations), #29 (getUser). The check has
to compare the route to the SDK, because comparing either to a fixture cannot
see it.
sdk-envelopes.test.ts parses both sides and fails on any pair that disagrees,
with a baseline enforced in both directions like its sibling — a new mismatch
fails, and so does a stale entry.
**11 genuine mismatches are baselined.** Which side moves is a public-API
decision (#744), not something to settle inside a test.
Getting that number right took three corrections, all of which are why the
guard looks the way it does:
* "has a top-level `data` key" is too loose. It classified
PrerequisitesCheckResponse as wrapped — that type has a `data` field among
a dozen domain fields — and a live probe of /v1/prerequisites/check
confirmed the body is bare. An envelope is `data` plus nothing but
pagination/metadata keys.
* 39 SDK methods across six resources unwrap the envelope themselves
(`const res = await this.get<X>(p); return res.data`). Their declared type
describes the inner payload and is correct *because* the route wraps.
Comparing their declared type to the route reported all of them as broken;
11 of my first 22 baseline entries were this false positive.
* `return c.json({ data }, 200)` is shorthand for `{ data: data }`. Requiring
a colon to read a key called two correct routes bare.
Verified by attacking it rather than trusting a green run: flipping
legal.getCurrent to an envelope fails with "sdk says wrapped, route says bare",
and adding a baseline entry for a pair that agrees fails with "now agrees;
remove it". Both pass again once reverted.
Also bumps the sdk pointer to pick up #28 and #29. #743 should have carried
`git submodule update --init --recursive` and reset the submodule back to the
recorded commit after I had checked out the merged one. So main has been
carrying the honest route schema from #743 with the SDK type that contradicts
it.
Refs #744
Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 11, 2026
…type can catch (#746) Some routes wrap their success body in `{ data }` and some return it bare. The http client returns the parsed body verbatim, so a method declaring `Promise<UserProfile>` against a wrapping route actually resolves to `{ data: UserProfile }`. TypeScript never notices, because the generic is asserted — `this.get<UserProfile>(...)` — rather than inferred from the wire. And the msw handlers are written from the declared types, so the suite agrees with the type while the type disagrees with the API. That combination has produced three wrong contracts a green suite certified: Scaffald/sdk#21 (employers), #26 (organizations), #29 (getUser). The check has to compare the route to the SDK, because comparing either to a fixture cannot see it. sdk-envelopes.test.ts parses both sides and fails on any pair that disagrees, with a baseline enforced in both directions like its sibling — a new mismatch fails, and so does a stale entry. **11 genuine mismatches are baselined.** Which side moves is a public-API decision (#744), not something to settle inside a test. Getting that number right took three corrections, all of which are why the guard looks the way it does: * "has a top-level `data` key" is too loose. It classified PrerequisitesCheckResponse as wrapped — that type has a `data` field among a dozen domain fields — and a live probe of /v1/prerequisites/check confirmed the body is bare. An envelope is `data` plus nothing but pagination/metadata keys. * 39 SDK methods across six resources unwrap the envelope themselves (`const res = await this.get<X>(p); return res.data`). Their declared type describes the inner payload and is correct *because* the route wraps. Comparing their declared type to the route reported all of them as broken; 11 of my first 22 baseline entries were this false positive. * `return c.json({ data }, 200)` is shorthand for `{ data: data }`. Requiring a colon to read a key called two correct routes bare. Verified by attacking it rather than trusting a green run: flipping legal.getCurrent to an envelope fails with "sdk says wrapped, route says bare", and adding a baseline entry for a pair that agrees fails with "now agrees; remove it". Both pass again once reverted. Also bumps the sdk pointer to pick up #28 and #29. #743 should have carried `git submodule update --init --recursive` and reset the submodule back to the recorded commit after I had checked out the merged one. So main has been carrying the honest route schema from #743 with the SDK type that contradicts it. Refs #744 Co-authored-by: Claude Opus 5 <[email protected]>
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
anycasts and preserve font token handlinganyusages in theme utilities, providers, and scripts while addressing lint warningsTesting
https://chatgpt.com/codex/tasks/task_b_68d20667ce808331aa2614093b0325af