Skip to content

Fix Options<> excess-property guard under TypeScript 6.0 - #29

Closed
kac-axelor wants to merge 1 commit into
axelor:devfrom
kac-axelor:typescript-6.0-fix
Closed

kac-axelor wants to merge 1 commit into
axelor:devfrom
kac-axelor:typescript-6.0-fix

Conversation

@kac-axelor

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

Copy link
Copy Markdown
Contributor

Under TypeScript 6.0, unknown keys nested inside where/select/orderBy/create are silently accepted: 6.0 preserves the exact argument shape when inferring generics (microsoft/TypeScript#63515), so the previous per-slot T[K] check compared the inferred value against itself. The Options<> guard now checks every key against the declared shape (U[K]) instead, with a phantom branch keeping T inferable so Payload<T, U> still narrows to the selected fields.

Functionally: typos like contact.find({ where: { addresses: { bogus: 1 } } }) are compile errors again under 6.0, restoring 5.9 behavior at every nesting depth. No runtime change — the guard is a type-level wrapper on the repository method signatures.

Greens the nested excess-key cases in the type test suite (#27) once the TypeScript 6.0 upgrade (#28) is in.


Series (merge order): #27 type tests (red by design) → #28 TypeScript 6.0 upgrade → #29 Options<> guard fix → #30 mappedBy fix. The suite in #27 goes fully green once all four are merged.

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.
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