Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

fix(tsconfig): 根 tsconfig.node.json 加 noEmit,堵住全仓排放 - #3574

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-3549-node-tsconfig-emit-guard
Aug 7, 2026
Merged

yinlianghui merged 1 commit into
mainfrom
claude/issue-3549-node-tsconfig-emit-guard

Conversation

@yinlianghui

Copy link
Copy Markdown
Contributor

Fixes #3549

问题

根 tsconfig.node.json 既没有 include(默认编译整个仓库),又从 tsconfig.base.json 继承了 declaration / declarationMap / sourceMap 且没有 outDir。任何一次 tsc -p tsconfig.node.json 都会在每个源文件旁边写出 .js / .d.ts / .map,而且这些形状全部不在 .gitignore 里。

objectui#3515 已经实测踩爆过一次:一条随手的 git add -A 吞进 402,729 行插入;更糟的是排放出的 .js 带 JSX(来自 .tsx 输入),rolldown 会优先解析 src/lib/utils.js 而不是 src/lib/utils.tsx,于是 @object-ui/components:build 报出 165 个 "Unexpected JSX expression",读起来像"你的改动弄坏了构建",实际与任何改动无关。

修法

取最小静态防线:给 compilerOptions 加 "noEmit": true,并补一段文件头注释说明来由(避免下一个编辑者当作冗余删掉)。

选这条路而不是 .gitignore 退路,是因为前置排查确认没有任何东西依赖它的 emit。全仓 tsconfig.node.json 的引用共 8 处,逐条落定:

位置 指向 处置
apps/console/package.json:48 (tsc -b tsconfig.node.json --force) cwd 是 apps/console,解析到 apps/console/tsconfig.node.json 同名不同文件,不受影响
apps/console/tsconfig.json:28 (references: ./tsconfig.node.json) 同上,相对 apps/console/ 同名不同文件,不受影响
tsconfig.vitest-setup.json:14 散文注释,提到根文件 仅描述,无执行;且该描述("无 include、无 script 运行它")改后依然成立
tsconfig.vitest-setup.json:89、tsconfig.scripts.json:15、tsconfig.scripts.json:96 散文注释,提到 apps/console 那个 仅描述
scripts/__tests__/vitest-setup-type-check.test.ts:17、:143 散文注释 / 错误提示字符串 无任何断言读取根文件内容
turbo.json:26、.github/labeler.yml:80 (tsconfig*.json) 缓存 input glob / 打标签 glob 非执行;仅使 turbo hash 变化一次

另外确认:根 tsconfig.json 没有 references 数组,全仓所有 package 配置 extends 的都是 ../../tsconfig.json,没有任何工程 extends 或 references 根 tsconfig.node.json —— 所以 TS6310(被引用工程不得 noEmit)不适用。tsconfig.scripts.json 与 tsconfig.vitest-setup.json 各自也是同一个论证(两者都是 standalone + noEmit: true)。

逆向验证

方向是先预测后跑的。修前预测:排放物出现;修后预测:退出码记录、零新文件落盘、诊断数不变。

BEFORE(origin/main) AFTER(本 PR)
git status --porcelain 条目 5,850(全部 ?? 未跟踪) 0(只剩被改的 tsconfig.node.json 本身)
git clean -dn 5,850 0
tsc 退出码 1 2
诊断数 23,903 23,902

排放物构成:1,435 个 .js、1,434 个 .ts(即 .d.ts)、2,979 个 .map,加 1 个 .mjs / 1 个 .mts。抽查 issue 点名的四个路径,git check-ignore 全部 NOT ignored,与 issue 的表格一致。

两个数字与我的预测不符,都查清了,而且两个都是"修好了"的证据,不是回归:

  1. 退出码 1 → 2 不是变坏。 tsc 的约定是:1 = 报了错但仍生成了输出,2 = 报了错且没有生成任何输出。退到 2 正是 emit 停止的机器可读确认。

  2. 少掉的那 1 条诊断是 emit-only 诊断。 逐行 diff 后只有一条消失、零条新增:

    packages/components/src/__tests__/test-utils.tsx(16,17): error TS2883:
    The inferred type of 'renderComponent' cannot be named without a reference to ...
    

    TS2883 只在 TypeScript 必须写出 .d.ts 却无法可移植地命名推断类型时才产生。关掉 emit 就不再写声明,该诊断自然不产生。也就是说:本 PR 只动 emit、不动检查,而唯一变化的诊断恰好属于 emit 本身。既有的 ~23.9k 错误原样保留(那份积压按 objectui#3515 的裁定不在本次范围内;issue 记录的 21,616 是当时的数,随 main 漂到了 23.9k)。

同时确认 TS5053(declaration 与 noEmit 并用)与 TS6310 均未出现 —— TS 6.0.3 下二者可共存。

门禁

命令 结果
pnpm type-check:scripts EXIT=0
pnpm type-check:vitest-setup EXIT=0
pnpm check:control-bytes OK(扫描 3,631 个跟踪文本文件)
pnpm type-check:coverage EXIT=0
vitest run scripts/__tests__/{vitest-setup-type-check,scripts-type-check}.test.ts 2 files / 19 tests passed

type-check:vitest-setup 在全新 worktree 里初跑是红的(4 条 TS2882,@object-ui/components / fields / plugin-dashboard / plugin-grid 找不到声明)。这是 CI 注释写明的 ^build 前置缺失,不是本改动引起:把本 PR 的改动撤回到未修改的 origin/main 再跑,得到逐字相同的 4 条;补建这四个包及其依赖后,该门禁 EXIT=0。

备注

  • 无 changeset:根开发配置,不面向用户。
  • 未触碰 content/docs/releases/。
  • 排放物清理过程严格避开了本 issue 描述的陷阱:全程在独立 worktree 内,git clean -fdn 先预演(5,850 条,零 node_modules 命中)再执行,清理后 git status --porcelain 与 git clean -dn 双双归零;没有用过 git add -A。

Generated by Claude Code

根 `tsconfig.node.json` 既没有 `include`(默认编译整个仓库),又从
`tsconfig.base.json` 继承了 `declaration` / `declarationMap` / `sourceMap`
且没有 `outDir`。任何一次 `tsc -p tsconfig.node.json` 都会在每个源文件旁边
写出 .js / .d.ts / .map,实测 5,850 个,且全部不在 .gitignore 里。

objectui#3515 已经踩爆过一次:一条随手的 `git add -A` 吞进 402,729 行插入;
更糟的是排放出的 .js 带 JSX(来自 .tsx 输入),rolldown 会优先解析
`src/lib/utils.js` 而不是 `src/lib/utils.tsx`,于是
`@object-ui/components:build` 报出 165 个 "Unexpected JSX expression",
读起来像"你的改动弄坏了构建",实际与任何改动无关。

修法取最小静态防线:加 `"noEmit": true`。该文件是纯编辑器/引用配置,
全仓没有任何 script 运行它;它不被任何工程 `references`,所以 TS6310 不适用
——`tsconfig.scripts.json` 与 `tsconfig.vitest-setup.json` 各自也是这个论证。
同时补一段文件头注释说明来由,避免下一个编辑者当作冗余删掉。

只改 emit,不改检查:该工程既有的 ~23.9k 错误原样保留(那份积压按
objectui#3515 的裁定不在本次范围内)。

Fixes #3549

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 7, 2026 2:14pm

Request Review

@yinlianghui
yinlianghui marked this pull request as ready for review August 7, 2026 14:16
@yinlianghui
yinlianghui added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit c35fed0 Aug 7, 2026
16 checks passed
@yinlianghui
yinlianghui deleted the claude/issue-3549-node-tsconfig-emit-guard branch August 7, 2026 14:16
os-sales pushed a commit that referenced this pull request Sep 18, 2026
…the carve-out it stopped covering

`packages/types/tsconfig.test.json` closed with an invariant in the imperative:

> Every test file in this package is compiled; keep it that way.

It is false today, and it is false in the file that states it.

## ROTTED, not born false — the falsifier is one commit

Orphans = files under `packages/types/src/__tests__/` matching neither
`src/**/*.test.ts` nor `src/**/*.test.tsx`. Re-derived here per ref with
`git ls-tree`, each zero carried by a lit control on the same instrument
and the same corpus (the files that DO match):

| ref | date | what it is | orphans | [LIT CTRL] in the program |
|---|---|---|---|---|
| `c35fed098` | 2026-08-07 | the sentence's write-time ref (PR #3574) | 0 | 28 |
| `dd5b01b59` | 2026-09-02 | `DIST_PIN_GLOB` / the `dist` project lands (PR #7291) | 0 | 85 |
| `8195905bf` | 2026-09-09 | the commit before the falsifier | 0 | 152 |
| `1ccfc235e` | 2026-09-09 | the falsifier — PR #8646 adds the file | 1 | 153 |
| `1cfdff814` | today | `origin/main` | 1 | 204 |

The `include` line at the write-time ref is byte-for-byte the one in force
today, so the sentence did not drift by its own config moving — the
population moved under it. Independently of which commit wrote the sentence:
tree-wide, zero `.dist.spec.tsx` files existed at `c35fed098` (lit control:
3716 tracked files), so the construction that falsifies it did not yet exist.
TRUE when written, falsified on 2026-09-09.

⇒ kept and dated rather than overwritten (#9713). Overwriting it would erase
that it was ever true.

## The exclusion is a construction, not a hole

The `.dist.spec.tsx` suffix keeps the built-artifact pins out of this program
deliberately: turbo's `type-check` waits on `^build` (the DEPENDENCIES'
builds) and must never be handed a program that reads this package's own
`dist` — #4801 removed a self-referencing `paths` entry for that reason. The
pins are still RUN, by the opt-in `dist` vitest project (`DIST_PIN_GLOB`,
#7183). A declared exclusion and a hole look identical in a directory
listing, and the false sentence pointed at the wrong one, so the amended
invariant now states the carve-out, its reason and its runner.

No count is written into the prose (AGENTS.md #9): the comment points at
`pnpm type-check:coverage`, which re-derives the claim and shares the same
`*.test.ts(x)` definition. `vitest.config.mts` is cited by the `DIST_PIN_GLOB`
symbol, never by line (AGENTS.md #11).

## Nothing a program reads changed — measured

`tsc -p <cfg> --noEmit --listFiles` for all three of this package's
`type-check` legs (`tsconfig.json`, `tsconfig.examples.json`,
`tsconfig.test.json`) is byte-identical before and after; `diff` exits 0 on
each. No `include`, no `exclude`, no compiler option, no test file moved.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UanLVj6xvbS6puBCewLr8L
akarma-synetal pushed a commit to akarma-synetal/objectui that referenced this pull request Sep 28, 2026
…the carve-out it stopped covering (objectstack-ai#9750)

Fixes objectstack-ai#9737

Clause-②: no

`packages/types/tsconfig.test.json` closed with an invariant in the
imperative — *"Every test file in this package is compiled; keep it that
way."* — which is false today, and false in the file that states it.
This amends that one comment, and nothing else.

## The verdict was measured, not inherited — ROTTED, not born false

Orphans = files under `packages/types/src/__tests__/` matching
**neither** `src/**/*.test.ts` nor `src/**/*.test.tsx`. Re-derived per
ref with `git ls-tree` in this branch's worktree, never from a working
tree. Every zero carries a **lit control on the same instrument and the
same corpus** — the files that DO match — so a zero is a reading, not a
dead probe.

| ref | date | what it is | orphans | **[LIT CTRL]** files in the
program |
|---|---|---|---|---|
| `c35fed098` | 2026-08-07 | the sentence's write-time ref (PR objectstack-ai#3574) |
**0** | 28 |
| `dd5b01b59` | 2026-09-02 | `DIST_PIN_GLOB` / the `dist` project lands
(PR objectstack-ai#7291) | **0** | 85 |
| `8195905bf` | 2026-09-09 | the commit immediately before the falsifier
| **0** | 152 |
| `1ccfc235e` | 2026-09-09 | **the falsifier** — PR objectstack-ai#8646 adds the file
| **1** | 153 |
| `1cfdff814` | today | `origin/main` at branch point | **1** | 204 |

The orphan is
`packages/types/src/__tests__/zod-subpath-single-module-8598.dist.spec.tsx`.

Two independent legs establish ROTTED rather than BORN FALSE:

1. The `include` line at the write-time ref is **byte-for-byte** the one
in force today (`diff` of the two lines exits 0) ⇒ the sentence did not
drift by its own config moving; the population moved under it.
2. Tree-wide at `c35fed098`, the count of `.dist.spec.tsx` files is
**0** (lit control: 3716 tracked files at that ref) ⇒ the construction
that falsifies the sentence **did not yet exist anywhere in the repo**
when it was written. This leg holds whichever commit is taken to be the
write-time ref, so the verdict does not rest on `git log -S` in a
shallow checkout.

`git log -S'Every test file in this package is compiled'` over that path
returns `c35fed098` and nothing else in the fetched window.

⇒ TRUE when written, true for thirty-three days, falsified on 2026-09-09
by a single identified commit. So the sentence is **kept and dated**,
not overwritten — overwriting it would erase that it was ever true
(objectstack-ai#9713).

## What the repair says now

The exclusion the sentence stopped covering is **a construction with a
stated reason and a cited card**, not a hole — and a declared exclusion
and a hole look identical in a directory listing. The amended invariant
therefore states all three things a reader would otherwise have to
re-derive:

- **the carve-out** — the `.dist.spec.tsx` built-artifact pins are
outside this program;
- **its reason** — turbo's `type-check` waits on `^build` (the
DEPENDENCIES' builds) and must never be handed a program that reads this
package's own `dist`; objectstack-ai#4801 removed a self-referencing `paths` entry for
exactly that reason;
- **its runner** — the pins are still RUN, by the opt-in `dist` vitest
project (`DIST_PIN_GLOB`, env-gated, reached through `pnpm test:dist`),
built on purpose by objectstack-ai#7183.

Two repo rules shaped the wording:

- **AGENTS.md objectstack-ai#9** — no count is written into the prose. The comment
points at `pnpm type-check:coverage`
(`scripts/check-type-check-coverage.mjs`), which re-derives the claim
and happens to share the same `*.test.ts(x)` definition, so the two
agree by construction rather than by coincidence.
- **AGENTS.md objectstack-ai#11** — `vitest.config.mts` is cited by the
`DIST_PIN_GLOB` **symbol**, never by a cross-file line address. `pnpm
check:new-line-citations` prints `0 new citation(s)` for this branch.

## ⛔ What did NOT change — measured, not asserted

No `include`, no `exclude`, no compiler option, no test file moved.
Proven at the level of program inputs rather than of the diff:

`tsc -p CONFIG --noEmit --listFiles`, run for all three legs of this
package's `type-check` script, **before and after** the edit:

| program | exit | `--listFiles` diff, before vs after |
|---|---|---|
| `tsconfig.json` | 0 | `diff` exit **0** — byte-identical |
| `tsconfig.examples.json` | 0 | `diff` exit **0** — byte-identical |
| `tsconfig.test.json` | 0 | `diff` exit **0** — byte-identical |

On that same `--listFiles` output for `tsconfig.test.json`: the orphan
pin appears **0** times, and the lit control
`src/__tests__/base-bind-declared.test.ts` appears **1** time — the
carve-out read directly off the real program, not off the globs.

## Gates

Exit codes captured to disk before any pipe.

| gate | exit | verdict line |
|---|---|---|
| `pnpm --filter @object-ui/types type-check` (all three legs) | **0** |
`tsc --noEmit && tsc -p tsconfig.examples.json && tsc -p
tsconfig.test.json` |
| `pnpm exec vitest run packages/types/` (repo root) | **0** | `Test
Files 204 passed (204)` · `Tests 4771 passed (4771)` |
| `pnpm type-check:coverage` | **0** | `test type-check coverage: 43/43
packages compile their tests, 0 declared debt` |
| `node scripts/check-changeset-presence.mjs` | **0** | `No source or
published contract of a released package changed in this range` |
| `pnpm check:new-line-citations` | **0** | `0 new citation(s),
enforcement report-only` |
| `pnpm check:control-bytes` | **0** | `OK (scanned 7840 tracked text
file(s))` |
| `pnpm check:published-tsconfig-exclude` | **0** | |
| `pnpm check:self-import` | **0** | |
| `pnpm check:changeset-claims` | **0** | |
| `pnpm check:pending-changeset-literals` | **0** | |
| `pnpm check:comment-mask-corpus` | **0** | |
| `pnpm census:tsconfig-test-parity` | **0** | |
| `node scripts/check-governed-queue-guard.mjs --test` (both changed
paths) | **0** | `NOT GOVERNED — 2 path(s) checked against 5 governed
surface(s)`; **[LIT CTRL]** `AGENTS.md` ⇒ exit 3, `GOVERNED` |

All figures above were taken at `837cea2f9`, this branch's final commit.

**Repo-wide `pnpm lint` is CI's run; the local narrowing is declared and
proven.** eslint's own flat config declares its universe as
`**/*.{ts,tsx}` (plus `**/*.tsx`) and nothing else; run over the two
changed paths with `--no-inline-config --format json` it reports **2**
files, **0** errors, and for each one its own message *"File ignored
because no matching configuration was supplied."* No `.ts`/`.tsx` file
changed at all, and no tsconfig program input moved (table above), so no
untouched file's verdict can move either.

## The changeset grade is MEASURED

`packages/types`' `files[]` is `["dist", "README.md", "CHANGELOG.md",
"LICENSE"]`, so anything reaching `dist` publishes. After `pnpm --filter
@object-ui/types build`, scanning all **130** emitted `dist` files:

| probe | hits |
|---|---|
| `DATED READING` (bytes this PR adds) | **0** |
| `Every test file in this package is compiled` (bytes this PR keeps and
quotes) | **0** |
| `DIST_PIN_GLOB` (bytes this PR adds) | **0** |
| **[LIT CTRL]** source-comment prose known to ship (`registry key`) |
**5** — `field-types.d.ts`, `zod/node-derivation.d.ts`, … |
| **[ABSENT CTRL]** a nonsense token | **0** |

The lit control proves the instrument is connected on the same corpus,
and the absent control proves it is not matching everything. ⇒ nothing
published moved, and the changeset declares that with **empty
frontmatter** — which is the claim, made explicitly rather than by
analogy to a `base.ts` comment (whose prose *does* ship into
`dist/base.d.ts`, and would have been graded `patch`).

## A count is invariant under quotation — probed separately, both
reported

The repair quotes the old sentence, so quoted position and assertion
position were probed apart with a whitespace-tolerant whole-content scan
(`git grep` is line-anchored and this is wrapped JSON-with-comments):

| position | occurrences |
|---|---|
| total, any position | **1** (`packages/types/tsconfig.test.json`) |
| quoted position (opens with a double quote) | **1** |
| **assertion position** (total − quoted) | **0** |
| **[LIT CTRL]** `DATED READING`, known present and unquoted | **1** |
| **[ABSENT CTRL]** a nonsense token | **0** |

The changeset body carries one further occurrence, also in quoted
position. ⇒ no live, undated assertion of the sentence survives anywhere
in the tree.

## Acceptance notes

- **Measured in passing, and it dissolves rather than opens the second
card.** The dispatch fenced out "every package with a `.dist.spec.tsx`
pin and a `tsconfig.test.json` may carry the same sentence-vs-population
question". Tree-wide there are exactly **2** `.dist.spec.tsx` files (lit
control: 7925 tracked files), in `packages/types` and
`packages/components`, and both packages do have a `tsconfig.test.json`.
But the whole-content scan for the invariant sentence returns **1** hit,
in `packages/types` only: `packages/components/tsconfig.test.json`
states no such invariant. ⇒ there is no second site to repair. Noted,
not filed; handed back to the dispatching seat.
- The triage seat's optional escalation probe (has anyone already
widened an `include` on the strength of this sentence ⇒ p1) reads
**negative** in the fetched window: the only two commits touching
`packages/types/tsconfig.test.json` are `c35fed098` and `4e96becf5`, and
the latter moved `lib` only. ⚠️ The checkout is shallow, so this is a
NOT-FULLY-MEASURED negative rather than a proven absence.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01UanLVj6xvbS6puBCewLr8L)_

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Root tsconfig.node.json emits build artifacts next to every source — 5,838 files, none of them gitignored

2 participants