diff --git a/integrationTests/ts/index.ts b/integrationTests/ts/index.ts index 65f3a7a1d2..6ef6bea899 100644 --- a/integrationTests/ts/index.ts +++ b/integrationTests/ts/index.ts @@ -96,27 +96,43 @@ if (data != null) { const typedData: ResponseData = data; } -declare function runQueryA(q: TypedQueryDocumentNode<{ output: string }, { input: string | null }>): void; +declare function runQueryA( + q: TypedQueryDocumentNode<{ output: string }, { input: string | null }>, +): void; // valid -declare const optionalInputRequiredOutput: TypedQueryDocumentNode<{ output: string }, { input: string | null }>; +declare const optionalInputRequiredOutput: TypedQueryDocumentNode< + { output: string }, + { input: string | null } +>; runQueryA(optionalInputRequiredOutput); -declare function runQueryB(q: TypedQueryDocumentNode<{ output: string | null }, { input: string }>): void; +declare function runQueryB( + q: TypedQueryDocumentNode<{ output: string | null }, { input: string }>, +): void; // still valid: We still accept {output: string} as a valid result. // We're now passing in {input: string} which is still assignable to {input: string | null} runQueryB(optionalInputRequiredOutput); // valid: we now accept {output: null} as a valid Result -declare const optionalInputOptionalOutput: TypedQueryDocumentNode<{ output: string | null }, { input: string | null }>; +declare const optionalInputOptionalOutput: TypedQueryDocumentNode< + { output: string | null }, + { input: string | null } +>; runQueryB(optionalInputOptionalOutput); // valid: we now only pass {input: string} to the query -declare const requiredInputRequiredOutput: TypedQueryDocumentNode<{ output: string }, { input: string }>; +declare const requiredInputRequiredOutput: TypedQueryDocumentNode< + { output: string }, + { input: string } +>; runQueryB(requiredInputRequiredOutput); // valid: we now accept {output: null} as a valid Result AND // we now only pass {input: string} to the query -declare const requiredInputOptionalOutput: TypedQueryDocumentNode<{ output: null }, { input: string }>; +declare const requiredInputOptionalOutput: TypedQueryDocumentNode< + { output: null }, + { input: string } +>; runQueryB(requiredInputOptionalOutput); diff --git a/src/utilities/typedQueryDocumentNode.d.ts b/src/utilities/typedQueryDocumentNode.d.ts index 42979fdaaf..0d7b8de17d 100644 --- a/src/utilities/typedQueryDocumentNode.d.ts +++ b/src/utilities/typedQueryDocumentNode.d.ts @@ -14,5 +14,7 @@ export interface TypedQueryDocumentNode< * and that the Result is assignable to whatever you pass your result to. The method is never actually * implemented, but the type is valid because we list it as optional */ - __ensureTypesOfVariablesAndResultMatching?: (variables: TRequestVariables) => TResponseData; + __ensureTypesOfVariablesAndResultMatching?: ( + variables: TRequestVariables, + ) => TResponseData; }