Repository navigation
Fix Options<> excess-property guard under TypeScript 6.0 - #29
Closed
kac-axelor wants to merge 1 commit into
Closed
kac-axelor wants to merge 1 commit into
kac-axelor wants to merge 1 commit into
Conversation
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.
This was referenced Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. TheOptions<>guard now checks every key against the declared shape (U[K]) instead, with a phantom branch keepingTinferable soPayload<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.