Skip to content

Upgrade to TypeScript 6.0 with the Options excess-property guard fix - #34

Open
kac-axelor wants to merge 2 commits into
axelor:devfrom
kac-axelor:typescript-6.0
Open

kac-axelor wants to merge 2 commits into
axelor:devfrom
kac-axelor:typescript-6.0

Conversation

@kac-axelor

@kac-axelor kac-axelor commented Jun 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

TypeScript 6.0 changes generic inference: the compiler preserves the exact
argument shape when inferring generics (microsoft/TypeScript#63515). That
made the Options<> per-slot T[K] check compare the inferred value against
itself, so unknown keys nested inside where/select/orderBy/create
were silently accepted under 6.0. This PR upgrades to 6.0 with the guard
reworked to stay inference-proof, preserving full 5.9 behavior.

What the guard fix restores

Given an invalid query — an unknown key nested in the options, e.g.
where: { title: { name: "x", bogusR: 1 } }:

Compiler Outcome for the invalid query
TypeScript 5.9 rejected at compile time (correct)
TypeScript 6.0, previous guard accepted silently — the typo ships and the filter never matches
TypeScript 6.0, this PR rejected at compile time (5.9 behavior restored)

Commits

Ordered so every commit is green — the guard rework behaves identically
under 5.9, so it lands first:

Commit Contents State after
Fix Options<> excess-property guard under TypeScript 6.0 inference-proof Options<> (each slot typed from the expected shape, with a never-matched marker key as the inference handle) green under 5.9
Upgrade TypeScript to 6.0 typescript ^5.9.3 → ^6.0.3; types: ["node"] in tsconfig (6.0 no longer auto-includes everything under node_modules/@types) green under 6.0

Validation

Check TS 5.9 (commit 1) TS 6.0 (commit 2)
pnpm test (unit) 147/147 147/147
pnpm build OK OK
pnpm test:e2e (real PostgreSQL) — 215/215

TS 6.0 preserves the argument's exact shape when inferring generics
(microsoft/TypeScript#63515), so the prior T[K]-per-slot guard silently
accepted unknown keys at nested depths. Switch to U[K] (the declared
shape); a phantom branch keeps T[K] as an inference anchor so
Payload<T, U> still narrows to selected fields.
TS 6.0 no longer auto-includes node_modules/@types, so declare
types: ["node"] explicitly for the Buffer/process/node:* usage.
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