Skip to content

fix(engine): typecheck saves with TypeScript 6 so @types/node 26 projects save - #197

Open
Upd4ting wants to merge 1 commit into
mainfrom
fix/builder-typecheck-node-types-26
Open

Upd4ting wants to merge 1 commit into
mainfrom
fix/builder-typecheck-node-types-26

Conversation

@Upd4ting

Copy link
Copy Markdown
Member

Why

Every Builder save in a project on @types/node 26 fails, so the Builder can't edit template-dms-demo at all. Found by ANT-2135 while retesting template-dms-demo#170. The Builder typechecks each save with ts-morph 23, which bundles TypeScript 5.5.2. That compiler can't read @types/node 26 (Cannot find name 'IteratorObject'). As a result it rejects createInterface({ input }) in the demo's src/capture-start.ts:106 with No overload matches this call, even though the project's own TypeScript 7.0.2 accepts that line.

What

  • ts-morph goes from ^23.0.0 to ^28.0.0, which bundles TypeScript 6.0.2. That version reads @types/node 26.
  • The CHECKER_MODULE = "preserve" swap in engine/project.ts is deleted. It only existed because TypeScript 5.5 rejected moduleResolution: "bundler" with module: "commonjs". TypeScript 6 accepts that pair, so a project without a tsconfig.json is now checked with the template's own options.
  • The module's @types/node dev dependency goes to ^26.6.5 so the new spec checks against it.
  • New spec node-types-typecheck.spec.ts. It saves a category and a page in a project on @types/node 26 that uses the DMS template's compiler options, with a file that calls createInterface({ input }) on a child's streams. A checker on TypeScript 5.5 fails it.

Two options were considered:

  • Use the project's own typescript. This doesn't work for the project that hit the bug. TypeScript 7 (typescript@7.0.2) ships the native compiler, and its package exports only version and an unstable/sync API, not the compiler API that ts-morph drives. ts-morph can't load it.
  • Use a ts-morph that bundles a newer TypeScript. ts-morph 28 is the latest and the only change needed. The engine builds and passes its suites on it with no source changes beyond the deleted workaround.

Proof

New spec, with ts-morph 23 (main) and @types/node 26 installed:

  1) a project on @types/node 26
       saves a new category and a page in it:
     Error: CreateCategory failed: {"code":"typecheck_failed","diagnostics":[{"file":".../.test-app-915519/src/capture.ts","line":7,"message":"No overload matches this call."}]}

After:

  a project on @types/node 26
    ✔ saves a new category and a page in it (1091ms)

  1 passing (1s)

End to end, on a fresh clone of template-dms-demo main (b9b19c7) after pnpm install --frozen-lockfile, with no edit. The engine's AddQuery adds a Sum of total over helio/invoices to Home, the same save path /api/builder calls:

main   {"compiler":"5.5.2","resource":"helio/invoices","ok":false,"error":{"code":"typecheck_failed","diagnostics":[{"file":".../ant2162-demo/src/capture-start.ts","line":106,"message":"No overload matches this call."}]}}
branch {"compiler":"6.0.2","resource":"helio/invoices","ok":true,"data":{"query":"/home@invoicedTotal","route":"/dms/pages/home/stats/invoiced-total"}}

The branch wrote src/home.ts and src/helio/finance/database.ts. Then the project's own pnpm exec tsc --noEmit (TypeScript 7.0.2) exits 0. ConfigurePage on /home gives the same result: main fails on capture-start.ts:106, and the branch saves.

  • pnpm --filter @antelopejs/dms-builder test:unit: 528 passing.
  • pnpm run checks: Checks: 12 passed, 0 failed.
flowchart LR
  save[Builder save] --> tx[Transaction.typecheckErrors]
  tx --> tsm[ts-morph 28 / TypeScript 6.0.2]
  tsm --> types["project's @types/node 26"]
  types -->|reads IteratorObject| ok[no diagnostic, file written]
Loading

…ects save

ts-morph 23 bundles TypeScript 5.5, which cannot read @types/node 26
(IteratorObject) and refuses every save in a project on it. ts-morph 28
bundles TypeScript 6.0, which also accepts moduleResolution bundler with
module commonjs, so the checker no longer swaps the module to preserve.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant