Skip to content

fix: validate published TSRX source with a consumer-shaped typecheck - #732

Merged
trueadm merged 10 commits into
octanejs:mainfrom
dudusotero:fix/consumer-typecheck-validation
Aug 13, 2026
Merged

trueadm merged 10 commits into
octanejs:mainfrom
dudusotero:fix/consumer-typecheck-validation

Conversation

@dudusotero

@dudusotero dudusotero commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Rescoped. Everything this PR originally carried has already landed on main: #734 was stacked on this branch, so merging it brought the consumer projects, the tsgo to tsrx-tsc migration and the source-publication guardrail along with it. What remains here is one fix, for the fourth Bugbot finding on this PR.

The generated consumer projects omitted compilerOptions.types in order to mirror what octane init writes. The two omissions mean opposite things. A freshly scaffolded application has no @types/* installed at all, so omitting the field grants nothing. These projects run inside the monorepo, where omitting it makes TypeScript auto-include every installed @types/*, including @types/node.

So the projects were handing published source the Node globals a browser application never gets. That is the exact condition they exist to catch: it is gap C from #721, the one where process.env.NODE_ENV in published source is an error for a real consumer and invisible to us.

Confirmed with a probe compiled under the base config from inside the repo, before and after:

// before
export const x: string | undefined = process.env.NODE_ENV;   // no error

// after
error TS2591: Cannot find name 'process'. Do you need to install type
definitions for node? Try `npm i --save-dev @types/node` and then add 'node'
to the types field in your tsconfig.

types: [] is now set explicitly, with a comment recording why it deliberately diverges from the scaffolded template rather than tracking it. createPackedTsrxConsumerConfig already pins it the same way for the same reason, so the in-repo projects and the packed-tarball consumer now agree.

The generator test is split accordingly: one case still asserts that every scaffolded option reaches the consumer projects unchanged, and a second states the deliberate divergence and asserts both halves of it, so the next person to compare the two files finds the reason instead of a discrepancy.

Refs #721.

Validation

  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted tests:
    • node --test scripts/generate-consumer-tsconfigs.test.mjs scripts/check-source-publication.test.mjs (21 passed)
    • pnpm consumer:tsconfigs:check (52 projects, no drift after regeneration)
    • pnpm sync (clean, no generated drift)
    • the before/after probe above

pnpm test was not run against this commit. The diff is three files of generated-config tooling with no runtime reach; the suite ran green on this branch's earlier heads, and CI runs it here.

Risk / follow-ups

Pinning types: [] makes the consumer projects stricter than they were, so a package that appeared to pass one may now report process, Buffer or similar. That is the point, and it is why the projects are deliberately not in a CI gate yet. SOURCE_PUBLICATION_DEBT is unaffected: the guardrail reads package tsconfigs, not these projects, and stays at 112.

extends is still not resolved when reading a package tsconfig, so a config inheriting types: ["node"] from a base is not reported. Pre-existing and out of scope here.

Provenance

  • An agent produced this diff (agent-authored)

Note

Low Risk
Config-only change to validation tooling; may surface new type errors in consumer projects but does not affect runtime or the main CI typecheck gate.

Overview
Consumer-shaped typecheck projects now set compilerOptions.types to [] in the generated base config and in createConsumerBaseConfig, with comments explaining why this intentionally diverges from octane init (omitted types in a fresh app vs. monorepo auto-including every @types/*).

That closes a gap where published source could reference Node globals like process without error in-repo while real browser consumers would fail.

Tests split scaffold parity (all options except types) from a dedicated case asserting types: [] on consumer configs and undefined on the scaffold template.

Reviewed by Cursor Bugbot for commit 087a731. Bugbot is set up for automated code reviews on this repo. Configure here.

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.
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Aug 12, 2026
Comment thread scripts/check-source-publication.mjs Resolved
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.
Comment thread scripts/check-source-publication.mjs Resolved
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.
Comment thread scripts/check-source-publication.mjs Resolved
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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit cdca961. Configure here.

Comment thread scripts/generate-consumer-tsconfigs.mjs Resolved
Fourth Bugbot finding, confirmed. The generated projects omitted `types` to
mirror `octane init`, but the two omissions mean opposite things. A freshly
scaffolded app has no `@types/*` installed at all; these projects run inside
the monorepo, where an omitted `types` makes TypeScript auto-include every
installed one. Published source was being handed the Node globals it must
not see, which is the exact gap these projects exist to catch.

Proved before and after with a probe compiled under the base config inside
the repo: `process.env.NODE_ENV` resolved cleanly, and now reports TS2591.

The packed-tarball consumer already pins `types` empty for the same reason,
so this makes the in-repo projects agree with it.
…k-validation

# Conflicts:
#	scripts/consumer-tsconfigs/base.json
#	scripts/generate-consumer-tsconfigs.mjs
#	scripts/generate-consumer-tsconfigs.test.mjs
@dudusotero
dudusotero marked this pull request as ready for review August 13, 2026 14:54
@trueadm
trueadm merged commit feab975 into octanejs:main Aug 13, 2026
42 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants