From a8de07fdd8266f3a793bcd070a4e0ab467b1d7ce Mon Sep 17 00:00:00 2001 From: kac-axelor <215158475+kac-axelor@users.noreply.github.com> Date: Wed, 10 Jun 2026 18:42:58 +0530 Subject: [PATCH] Fix Options<> excess-property guard under TypeScript 6.0 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 still narrows to selected fields. --- src/client/types/base.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/client/types/base.ts b/src/client/types/base.ts index 109351f..cda5482 100644 --- a/src/client/types/base.ts +++ b/src/client/types/base.ts @@ -56,8 +56,17 @@ export type OmitByType = Pick< { [K in keyof T]-?: T[K] extends Type ? never : K }[keyof T] >; +// TS 6.0 infers the exact argument shape (unknown keys included), so T[K] +// checks a value against itself — excess keys pass. U[K] checks against the +// declared shape instead. The phantom-key branch keeps T[K] referenced so +// TypeScript still infers T and Payload still narrows to selected fields. +// https://github.com/microsoft/TypeScript/issues/63515 export type Options = { - [K in keyof T]: K extends keyof U ? T[K] : never; + [K in keyof T]: K extends keyof U + ? K extends "__use_T_so_it_is_inferred__" + ? T[K] + : U[K] + : never; }; export type OrderBy = "ASC" | "DESC";