Skip to content

Commit 32e5f6b

Browse files
committed
Remove comments
1 parent 4c5b332 commit 32e5f6b

1 file changed

Lines changed: 0 additions & 49 deletions

File tree

src/react/hooks/useQuery.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -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,
@@ -259,8 +234,6 @@ export declare namespace useQuery {
259234
TVariables extends OperationVariables,
260235
TOptions extends
261236
| Record<string, never> // no options
262-
// `Base.Options` instead of `Options` because the `variables` option is
263-
// not part of `TOptions` - see the `Modern` signatures for details.
264237
| Base.Options<TData, TVariables>
265238
| SkipToken,
266239
> = LazyType<
@@ -577,28 +550,6 @@ export declare namespace useQuery {
577550
}
578551

579552
/** {@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.
602553
export interface Modern {
603554
/** {@inheritDoc @apollo/client/react!useQuery.DocumentationTypes.useQuery:call(1)} */
604555
<

0 commit comments

Comments
 (0)