Repository navigation
fix(bindings): fix published source a browser app cannot type-check - #734
Merged
Merged
Conversation
Packages that ship .tsrx were typechecked by tsgo, which drops those files from the program entirely. Their published source was therefore never checked at all. Bindings publish raw source and point exports at it, so every one of those errors is visible to a consumer. - Generate canonical consumer projects from the same tsconfig the CLI scaffolds, with a drift check, so what is validated cannot diverge from what users actually compile against. - Move the .tsrx-publishing projects that already pass onto tsrx-tsc. - Add a no-@types/node lane to the packed-tarball canary. The existing lane sets types: ["node"], so it cannot see `process` references in published source, which a browser app does not resolve. - Add a guardrail over source-published packages with an enumerated allowlist of the remaining violations. A stale entry fails the check, so the list can only shrink.
octanejs#733 rebuilds the packed TSRX consumer canary around automatic discovery of every binding that ships .tsrx, which is a better answer than the package list this branch was extending. Drop the overlapping edits to package-pack-canaries.mjs, check-package-packs.mjs and their test so the two branches stop touching the same files. What remains here is the part octanejs#733 does not cover: the root typecheck chain still runs tsgo over packages that ship .tsrx, so those files are absent from the program CI actually runs.
These packages ship raw source and point exports at it, so a consumer's
program compiles every reachable module. The repo checked them with tsgo,
which drops .tsrx from the program, so none of this was visible in CI
while all of it was visible to consumers.
- Declare `process` module-locally at every published
`process.env.NODE_ENV` reference. A browser app has no @types/node. The
expression stays written out literally so bundler define substitution
and the dead-code elimination after it are unaffected, and nothing
ambient ships in the tarball.
- Let Form and Link accept a null forwarded ref: the compiler composes it
as ref={[ref, spread.ref]}, and Ref<T> array members cannot be undefined.
- Carry the same process deviation into the remix-router vendoring script,
so a re-vendor does not reintroduce the error.
The Provider prop typings for jotai and redux are left to octanejs#733, which
edits the same two files.
Two defects Cursor Bugbot found on this PR, both confirmed. The nodeTypes and excluded rules only saw projects discovered by parsing inline compiler invocations out of the root typecheck chain. A package validated through a package script, a node wrapper, or absent from the chain never entered the loop, so the gate stayed green while missing the defect it claims to block. They now walk each source-published package's own tsconfigs; the tsgo rule still follows the chain, since that rule genuinely is a claim about what the chain runs. The excluded rule matched an exclude entry only when it named a shipped file exactly, so `src`, `src/**` or `src/**/*.tsrx` could drop packed source without tripping it. Exclude entries are now translated into path predicates following tsc's own wildcard shape. The allowlist grows from 100 to 112. All twelve additions are node-types-in-validation-tsconfig entries that chain-only discovery could not see, including the four Bugbot named. The previous number was not the real debt, only the part the gate could reach.
trueadm
approved these changes
Aug 12, 2026
Third Bugbot finding, confirmed. The trailing `($|/)` was appended to every pattern, so a wildcard final segment behaved like a directory prefix: `src/*` matched `src/a/b/deep.ts` and `*` matched `src/a/b.ts`, where tsc's `*` and `?` do not cross `/`. Only a literal final segment, or `**` whose `.*` already spans, keeps the directory suffix now. Totals are unchanged at 112; no current entry depended on the over-match.
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
Stacked on #732. GitHub cannot base a fork PR on another fork branch, so the diff below also contains #732's commits. Review only
fix(bindings): fix published source a browser app cannot type-check(9 files, +65/-5).Scoped to avoid overlapping #733. That PR fixes the
Providerprop typings in jotai and redux; this one leaves those files alone and fixes what #733 does not touch. There is no file in common between the two.These packages ship raw source and point their exports at it, so a consumer's TypeScript program compiles every reachable module.
processis not available to a browser application. Published source referenced the bareprocess.env.NODE_ENVglobal in four modules. A scaffolded Octane app has no@types/node, so each one is a consumer-visible error. #733's browser lane includesnode_modules/@octanejs/**/*.tsrx, so these.tsmodules are not the files it compiles directly.The obvious fix is wrong, which is worth stating because it looks right. Reading the value through
globalThistype-checks, but a bundler'sdefinesubstitution matches the literal textprocess.env.NODE_ENV, and the dead-code elimination that follows removes the dev-only branch. Losing both would drop dev warnings under Vite and grow every consumer's production bundle. A module-localdeclare const processkeeps the expression written out literally, so both still work, and nothing ambient ships in the tarball. Verified with esbuild:FormandLinkrejected a forwarded ref. Both acceptedreftyped as possiblyundefined. The compiler composes a forwarded ref with the host spread's ref asref={[ref, spread.ref]}, and members of aRef<T>array cannot beundefined. They now acceptnull, whichattachRefalready treats as absent via its leadingif (ref == null) return;.packages/remix-router/src/lib/router/utils.tsis vendored and must not be hand-edited, so the same deviation is carried intoscripts/vendor-remix-router.mjs. Its note text is deliberately unchanged: the note is interpolated into the generated file header, so editing it would break the byte-for-byte round trip.Refs #721.
Validation
pnpm format:checkpnpm typecheckpnpm testpnpm vitest run --project jotai --project jotai-differential --project redux --project redux-differential --project remix-router --project remix-router-ssr --project remix-router-core --project remix-router-differential(33 files, 324 tests, all passing)pnpm exec tsrx-tsc --noEmit -p packages/remix-router/tsconfig.json(0 errors)pnpm changeset:checkformat:checkandtypecheckwere run with unrelated in-progress work removed from the tree, so they reflect this stack alone.pnpm testwas not run in full. It was run earlier over the whole working tree: 5 test files failed out of 2301, all pre-existing on this base. Running the same 5 projects against a cleanorigin/maincheckout gives 17 failing tests versus 16 here, and none touch a package this PR changes.Risk / follow-ups
jotai and redux are not promoted from
tsgoontotsrx-tschere, and keep theirSOURCE_PUBLICATION_DEBTentries, so this PR's diff stays what was reviewed.That is now the only thing holding the promotion back. #733 has merged, so with this branch on top all three packages report zero diagnostics under
tsrx-tscagainst their own tsconfig, measured just now: jotai 0, redux 0, remix-router 0. Promoting the two and dropping their entries is a small follow-up once this and #732 land, and #732's guardrail will reject the entries as stale at that point.No runtime test forwards a
refto<Form>or<Link>, so that change rests onattachRef's existing null guard and an unchanged suite rather than on direct coverage. Worth adding.Provenance
agent-authored)Note
Low Risk
Binding edits are typings and ref defaults with unchanged runtime behavior; broader script/tsconfig changes affect CI validation, not shipped app runtime.
Overview
Fixes consumer-visible TypeScript errors in
@octanejs/jotai,@octanejs/redux, and@octanejs/remix-router, which ship rawsrc/into app typecheck graphs.process.env.NODE_ENVin published modules now uses a module-localdeclare const processso browser apps without@types/nodecompile, while keeping the literal expression for bundlerdefine/ dead-code elimination. Applied in jotai hooks/utils, redux hooks, remix-routerutils.ts, and the vendor script that regenerates that file.FormandLinknow typerefasnull | Refwithref = nulldefault, fixing forwarded-ref composition asref={[forwarded, spread.ref]}where array members cannot beundefined.Also adds source-publication guardrails (stacked work):
check-source-publication.mjswith a shrinking debt allowlist, consumer-shaped tsconfig generation underscripts/consumer-tsconfigs/, and roottypecheck/bindings:typecheckupdates so more bindings usetsrx-tscinstead oftsgoon.tsrx. Patch changesets for the three binding packages.Reviewed by Cursor Bugbot for commit 192753a. Bugbot is set up for automated code reviews on this repo. Configure here.