fix(client/typescript): add a tsc gate and fix every defect it surfaced - #33
Open
juicycleff wants to merge 21 commits into
Open
fix(client/typescript): add a tsc gate and fix every defect it surfaced#33juicycleff wants to merge 21 commits into
juicycleff wants to merge 21 commits into
Conversation
…ller-only, when AbortSignal.any is unavailable
… leaking on reused signals
…nerators Two of the eight generators emitted `auth?: types.AuthConfig;` and read `this.config.auth` unconditionally, even when config.IncludeAuth is false. Since the type generator already gates AuthConfig out of types.ts when auth is disabled, this produced a non-compiling client (TS2694) whenever a spec has WebSocket or SSE endpoints and --no-auth is passed. All six other generators (rooms, presence, typing, channels, streaming_client, testing) were already gated; this closes the last two. The fixture corpus covered the auth axis and the WS/SSE axis separately but never crossed them, which is why the gate never caught this. Added a no-auth-ws-sse fixture crossing both axes, confirmed it reproduces the two TS2694 errors before the fix, and confirmed all 8 fixtures type-check clean after. Also folds in two related review findings: - streaming_client.go's JSDoc @example still showed `auth: { bearerToken }` regardless of config.IncludeAuth, advertising an option that doesn't exist on StreamingClientConfig with auth off. Gated the example line. - rest.go's tsPropertyKey had a dead `json.Marshal` error branch (Marshal never errors on a Go string). Removed it; behavior is unchanged for every input. Verified auth-ON output is byte-identical to eb67e91 across all six auth-enabled fixtures (diff -rq, zero differences). Verified auth-OFF generated websocket.ts has zero references to auth/AuthConfig; sse.ts has one inert comment only.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Conventional Commits ValidationPR Title: valid
Format
Types: |
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
The TypeScript client generator emitted code that did not compile and produced different output on every run. Nothing type-checked the generated output — every test assertion was
strings.Contains— which is why commit cc3364e had to be written reactively after a downstreamtsc --noEmitbroke.This branch adds a real
tsc --noEmitgate to the Go test suite over 8 spec/config fixtures, then fixes every defect the gate surfaced.go testnow fails if the generated TypeScript stops compiling.Measured before this branch, every fixture failed, including the default configuration:
defaultapiname(APIName: "APIClient")odd-keys(content-type,3dtiles)with-authno-streamingAll 8 fixtures now report zero.
Defects fixed
rest.tshardcodedimport { Client }whileclient.tsexportedclass <APIName>— broke every non-defaultAPINameAuthConfigreferenced but not exported, across 8 generators (generator.go, 5 streaming generators,testing.go, pluswebsocket.go/sse.go)content-typewas a syntax error, and a name containing'broke the wholetypes.tspackage.jsondeps, and pagination item-type selectionencodeURIComponentinsertIntoTreesilently discarded an entire namespace when a single-segment operation ID collided with an existing branchtoCamelCase("userId")returned"userid"; four near-duplicate copies consolidated into one rune-safe implementationAbortSignalsilently disabled the request timeoutinstanceof Errorfailed and theAbortErrorretry check could never matchTS2531errors inwebsocket.ts/sse.ts— files that had never been type-checkedVerification
go test -short -race -timeout=10mover all packages: exit 0, 41 packages ok, no data races.The gate is proven to bite, not assumed to: reverting
tsPropertyKeyin a scratch worktree turns it red with 10 errors. Theno-auth-ws-ssefixture was likewise verified to fail on the pre-fix generator with exactly the twoTS2694errors it targets.Auth-enabled generated output is byte-identical to before this branch across all fixtures — the auth gating changed only the auth-disabled path.
CI now installs Node 20 and
typescript@5.8.2so the gate runs there. It skips (rather than fails) when no TypeScript toolchain is present, so localgo teststill works without Node.Needs a decision
ci-summarydowngrades atestjob failure to a warning with noexit 1, while every other job hard-fails. The gate runs intest. If branch protection requires only "CI Summary", a red gate ships green. Pre-existing, deliberately left untouched here — worth resolving in or right after this PR, otherwise the gate is advisory.The Windows leg of the test matrix has never run the gate.
exec.LookPathshould resolvetsc.cmdvia PATHEXT, but that is reasoned, not verified — worth watching the first run.Scope
This is phase 1 of
docs/superpowers/specs/2026-07-24-ts-client-generator-design.md. The field-case mapping codec, type-generation depth, and the streaming rework with typed event maps are phases 2–4 and are not in this branch.Known gaps recorded for those phases:
webtransport.tsstill has no producer for its IR field and has never been type-checked; the generatedtests/directory sits outside the gate (jest types would requirenode_modules, and the gate is deliberately hermetic);HTTPErroranderrors.ts'screateErrorare two parallel hierarchies.