Skip to content

Commit 56067ee

Browse files
committed
fix(formula): give the test-typecheck program the node typings its two fixture-loading tests already assumed
`packages/formula` declared no `@types/node` and its test program named no `types`, so `node:fs` / `node:path` / `node:url` and `import.meta.url` never resolved in `tsconfig.test.json`. Adds the devDependency and the `types` entry, and re-records the shrink-only ledger. Ledger, measured on this branch with NO test file edited: before 5 file(s) / 15 error(s) / 12 pinned signature(s) after 3 file(s) / 7 error(s) / 4 pinned signature(s) The card's title generalised the cause to all 15; measured, it is 8 of the 15 — the whole of src/rls-predicate.test.ts and src/skill-catalog-sync.test.ts, which both GRADUATED. The surviving 7 are three unrelated classes in three other files and are not this cause. `tsconfig.json` — the BUILD config — is untouched, per its sibling's recorded rationale, and `packages/formula/dist` is byte-identical across the change (6 files, per-file sha256). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADLdAs2pVcH17h9tZKWMBg
1 parent eabdd66 commit 56067ee

4 files changed

Lines changed: 51 additions & 17 deletions

File tree

packages/formula/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@objectstack/spec": "workspace:*"
2525
},
2626
"devDependencies": {
27+
"@types/node": "^26.2.0",
2728
"typescript": "^6.0.3",
2829
"vitest": "^4.1.10"
2930
},
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"_comment": "Per-file tsc error debt of the @objectstack/formula TEST layer (#5286). `tsconfig.test.json` compiles `src/**/*.test.ts` — which `tsconfig.json` excludes and therefore no gate ever read — and every file below still carries errors from before that gate existed. THIS FIELD IS GENERATED: every regeneration rewrites it from scripts/check-test-typecheck.mts, and the EXACT ratchet below requires a regeneration on every repair — so an edit made here is gone by the next one. Anything true of THIS package goes in the sibling `_note` field, which is authored, is preserved verbatim, and is never written by the generator (#12624). This comment states NO cause for the errors, deliberately: the classes differ per package and per file, they move as the debt is paid down, and a cause written here is rewritten verbatim into every ledger by every regeneration — so it outlives its own repair and cannot be corrected in the file where it is read. Measure instead, before repairing anything: `tsc --noEmit --pretty false -p tsconfig.test.json` in the package prints the real classes with their TS codes. Each entry maps a file to its per-SIGNATURE error counts, never to a bare total (#13470): a signature is the TS code plus the diagnostic message with structural type blobs collapsed, and it carries NO line or column — so the pin survives edits that move code around, and only stops matching when the error itself becomes a different error. EXACT ratchet, judged by re-running tsc: a file that gains errors is red, a file that loses them is red until its number is re-recorded, a file that reaches zero is red until its entry is deleted, a signature that ARRIVES or VANISHES is red even when the file total is unchanged, and a file NOT listed here may have no errors at all. Regenerate with: pnpm --filter @objectstack/formula gen:test-typecheck-debt",
3+
"_note": "#16297 paid down 8 of the 15 errors this ledger held, with NO test file edited: `@types/node` became a devDependency of this package and `tsconfig.test.json` gained `\"types\": [\"node\"]`, so the node typings finally reach the TEST program. `tsconfig.json` — the BUILD config — was deliberately not touched, and `packages/formula/dist` was measured byte-identical across the change. The 8 were the entire content of `src/rls-predicate.test.ts` and `src/skill-catalog-sync.test.ts`: TS2591 x6 naming `node:fs` / `node:path` / `node:url` as bare specifiers, and TS2339 x2 reading `import.meta.url`. Both files GRADUATED, so their entries are gone from `entries` and any error either of them gains is now red on arrival. WHAT THAT CARD GOT WRONG, recorded here because the number will outlive the card: it was titled \"15 of its test-typecheck ledger errors have one cause\", and measured, the cause was 8 of the 15 — exactly the set `tsconfig.test.json`'s header had named all along, before the card generalised it to the file total. The entries that remain are three unrelated classes in three other files (TS2739 in cel-to-filter, TS2345 in matches-filter-temporal-conformance, TS2352 in normalize); none of them is the node-typings cause and none was expected to move. The separating measurement is cheap and repeatable: `tsc --noEmit --pretty false -p tsconfig.test.json --types node`, run on the pre-repair tree with no package-local devDependency at all, already reported exactly these same 7.",
34
"entries": {
45
"src/cel-to-filter.test.ts": {
56
"TS2739: Type '…' is missing the following properties from type '…': id, organization_id, team_member_ids, department": 1
@@ -10,18 +11,6 @@
1011
},
1112
"src/normalize.test.ts": {
1213
"TS2352: Conversion of type '…' to type '…' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.": 3
13-
},
14-
"src/rls-predicate.test.ts": {
15-
"TS2339: Property 'url' does not exist on type 'ImportMeta'.": 1,
16-
"TS2591: Cannot find name 'node:fs'. 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.": 1,
17-
"TS2591: Cannot find name 'node:path'. 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.": 1,
18-
"TS2591: Cannot find name 'node:url'. 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.": 1
19-
},
20-
"src/skill-catalog-sync.test.ts": {
21-
"TS2339: Property 'url' does not exist on type 'ImportMeta'.": 1,
22-
"TS2591: Cannot find name 'node:fs'. 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.": 1,
23-
"TS2591: Cannot find name 'node:path'. 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.": 1,
24-
"TS2591: Cannot find name 'node:url'. 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.": 1
2514
}
2615
}
2716
}

packages/formula/tsconfig.test.json

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,58 @@
7373
// one that loses one is red until re-recorded, one that reaches zero is red
7474
// until its entry is deleted, a signature that ARRIVES or VANISHES is red even
7575
// at an unchanged file total, and a file NOT listed there may have no errors at
76-
// all. 24 of the 29 files carry no entry, so any error any of them gains is red
77-
// on arrival. This layer holds ZERO `@ts-expect-error` directives (grepped with
78-
// a positive control — the same grep hits `packages/spec/src`), so no pin here
79-
// was silently dead.
76+
// all. At 6a1e38244, 24 of the 29 files carried no entry, so any error any of
77+
// them gains is red on arrival. This layer holds ZERO `@ts-expect-error`
78+
// directives (grepped with a positive control — the same grep hits
79+
// `packages/spec/src`), so no pin here was silently dead.
80+
//
81+
// ⭐ REPAIRED (#16297) — the repair the paragraph above described as real and
82+
// deliberately deferred. `@types/node` is now a devDependency of this package
83+
// and this file names `"types": ["node"]`. It goes HERE and not in
84+
// `tsconfig.json` for the reason this header opens with: that file is the BUILD
85+
// config and stays exactly as it is. Measured, not assumed: `packages/formula/
86+
// dist` is byte-identical across the change (6 files, sha256 per file, built
87+
// before and after on the same tree), so nothing published moves and the test
88+
// program alone gains the typings its two fixture-loading tests already assumed.
89+
// Ledger effect, with NO test file edited: 15 -> 7 errors, 5 -> 3 files,
90+
// 12 -> 4 signatures. 26 of the 29 files now carry no entry.
91+
//
92+
// ⚠️ A COUNT CORRECTION that repair earned in its turn. #16297 is titled
93+
// "15 of its test-typecheck ledger errors have one cause". Measured here, the
94+
// node-typings cause is **8 of the 15** — precisely the TS2591 x6 + TS2339 x2
95+
// named in the paragraph above, confined to `src/rls-predicate.test.ts` and
96+
// `src/skill-catalog-sync.test.ts`. That paragraph always said 8; the card
97+
// generalised it to the file total. The 7 that SURVIVE are three unrelated
98+
// classes in three OTHER files — TS2739 x1 (`src/cel-to-filter.test.ts`),
99+
// TS2345 x3 (`src/matches-filter-temporal-conformance.test.ts`), TS2352 x3
100+
// (`src/normalize.test.ts`) — and none of them is this cause.
101+
//
102+
// ⚠️ `types` REPLACES rather than merges, exactly like the `paths` note above,
103+
// so naming `["node"]` also ENDS whatever automatic `@types/*` inclusion this
104+
// program had. Measured before naming it: the only package in the reachable
105+
// `node_modules/@types` is `node` itself, and the ledger reading above is the
106+
// proof that the replacement subtracted nothing.
107+
//
108+
// ⚠️ OF THE TWO LINES, THIS ONE IS THE LOAD-BEARING ONE, and the pair was
109+
// measured in both directions on a fully built closure rather than reasoned
110+
// about. `tsc -p tsconfig.test.json --types node` with NO package-local
111+
// devDependency at all already reports 7 — the entry alone does the whole job,
112+
// resolving `@types/node` from the root hoist. The complementary leg is the one
113+
// worth knowing: the devDependency WITHOUT this entry reports 15, unchanged,
114+
// so ⛔ adding `@types/node` to `package.json` on its own would have been a
115+
// no-op that looked like a repair. The devDependency earns its line by making
116+
// the dependency declared instead of borrowed, and it is the pairing
117+
// `packages/spec` (#5286), `packages/verify`, `packages/cli` and
118+
// `packages/drivers/driver-mongodb` all use.
119+
80120
{
81121
"extends": "./tsconfig.json",
82122
"compilerOptions": {
83123
"noEmit": true,
84124
"module": "esnext",
85125
"moduleResolution": "bundler",
86-
"lib": ["ES2022"]
126+
"lib": ["ES2022"],
127+
"types": ["node"]
87128
},
88129
"include": ["src/**/*"],
89130
"exclude": ["node_modules", "dist"]

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)