@@ -199,31 +199,6 @@ export declare namespace useQuery {
199199 skip : false ;
200200 }
201201
202- /**
203- * The options as they are checked at the parameter position of the `Modern`
204- * signatures, intersected with the inferred `TOptions`.
205- *
206- * `NoInfer` keeps this from becoming an inference site for `TVariables`.
207- *
208- * The two mapped types report variables that are not part of `TVariables` and
209- * options that are not part of `useQuery.Options`. `TOptions` cannot reject
210- * either on its own, because it is inferred from the very object literal being
211- * checked - every key the user writes becomes part of it. Two details matter
212- * for the option names:
213- *
214- * - `SkipToken` is excluded from `TOptions` first. A conditionally skipped
215- * query infers `TOptions` as a union of `SkipToken` and the options object,
216- * and `keyof` of that union is `never`, which would silently make the check
217- * a no-op.
218- * - The conditional is what keeps the passing case at `unknown` instead of an
219- * empty mapped type. An empty object type is not a weak type, and an
220- * intersection is only weak if every member is, so intersecting one in would
221- * turn the weak type check off for the whole parameter. That check is not
222- * only about rejecting options objects without a single known option - it
223- * also affects inference. Without it, an options argument of the type
224- * `SkipToken | { returnPartialData: false }` infers a `TVariables` that has
225- * lost the optionality of its properties.
226- */
227202 export type OptionsFor <
228203 TData ,
229204 TVariables extends OperationVariables ,
@@ -577,28 +552,6 @@ export declare namespace useQuery {
577552 }
578553
579554 /** {@inheritDoc @apollo/client/react!useQuery.DocumentationTypes.useQuery:call(1) } */
580- // Every check on the options lives at the parameter position, in
581- // `OptionsFor`. The constraint only describes the shape of an options
582- // object, because a constraint cannot do the checking.
583- //
584- // TypeScript widens fresh literals when inferring an object literal into a
585- // naked type parameter, so `useQuery(query, { variables: { type: "main" } })`
586- // infers the candidate `{ variables: { type: string } }`. A constraint that
587- // required the exact `TVariables` (`{ type: "main" }`) would reject that
588- // candidate, and TypeScript then silently substitutes the constraint for
589- // `TOptions` - discarding every other inferred option along with it. That is
590- // what made `returnPartialData: false` come back as `boolean` and put
591- // `"partial"` into `dataState`.
592- //
593- // Widening also means the constraint could not do the check even if it did
594- // not collapse: once `{ type: "nope" }` has widened to `{ type: string }`
595- // there is nothing left to distinguish it from a valid value. Only the
596- // parameter position still sees the literal.
597- //
598- // `NoInfer` on `TVariables` there is required. Without it,
599- // `VariablesOption<TVariables>` becomes an inference site and the widened
600- // `{ type: string }` candidate wins over the one from the document, which
601- // stops invalid variable values from being reported at all.
602555 export interface Modern {
603556 /** {@inheritDoc @apollo/client/react!useQuery.DocumentationTypes.useQuery:call(1) } */
604557 <
0 commit comments