diff --git a/src/core/watchQueryOptions.ts b/src/core/watchQueryOptions.ts
--- a/src/core/watchQueryOptions.ts
+++ b/src/core/watchQueryOptions.ts
@@ -220,7 +220,10 @@ export interface MutationBaseOptions<
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#optimisticResponse:member} */
   optimisticResponse?:
     | TData
-    | ((vars: TVariables, { IGNORE }: { IGNORE: IgnoreModifier }) => TData);
+    | ((
+        vars: TVariables,
+        { IGNORE }: { IGNORE: IgnoreModifier }
+      ) => TData | IgnoreModifier);
 
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#updateQueries:member} */
   updateQueries?: MutationQueryReducersMap<TData>;

diff --git a/src/__tests__/optimistic.ts b/src/__tests__/optimistic.ts
--- a/src/__tests__/optimistic.ts
+++ b/src/__tests__/optimistic.ts
@@ -9,6 +9,7 @@ import {
   ApolloLink,
   ApolloCache,
   MutationQueryReducersMap,
+  TypedDocumentNode,
 } from "../core";
 
 import { QueryManager } from "../core/QueryManager";
@@ -1089,6 +1090,25 @@ describe("optimistic mutation results", () => {
         resolve();
       }
     );
+
+    it("allows IgnoreModifier as return value when inferring from a TypedDocumentNode mutation", () => {
+      const mutation: TypedDocumentNode<{ bar: string }> = gql`
+        mutation foo {
+          foo {
+            bar
+          }
+        }
+      `;
+
+      const client = new ApolloClient({
+        cache: new InMemoryCache(),
+      });
+
+      client.mutate({
+        mutation,
+        optimisticResponse: (vars, { IGNORE }) => IGNORE,
+      });
+    });
   });
 
   describe("optimistic updates using `updateQueries`", () => {

Type error returning `IGNORE` object when using a generic `TypedDocumentNode` mutation
### Issue Description

There's a type error when returning the `IGNORE` sentinel object from `optimisticResponse` that is inferring from a `TypedDocumentNode<>`.

Given the following document:
![image](https://github.com/apollographql/apollo-client/assets/48073625/a74f9993-a2a8-4356-bfcc-e48fafe3f259)

We get the following type error:
![image](https://github.com/apollographql/apollo-client/assets/48073625/04ab406e-5c01-4dce-86bc-5bbf026a0845)

I've checked the type definitions and it's fixed if we explicitly return an union type instead of only returning the inferred type. I created a PR #11944 changing this.





### Link to Reproduction

https://codesandbox.io/p/sandbox/optimisticresponse-apollo-ts-error-mv34ws

### Reproduction Steps

_No response_

### `@apollo/client` version

3.10.8
