Repository: apollographql/apollo-client

Problem statement:
[4.0] Remove `TCacheShape` generic argument on `ApolloClient`
`TCacheShape` hasn't provided a ton of type-safety value so we plan to remove it in 4.0


Hints:

Patch:
diff --git a/integration-tests/next/src/libs/apolloClient.ts b/integration-tests/next/src/libs/apolloClient.ts
--- a/integration-tests/next/src/libs/apolloClient.ts
+++ b/integration-tests/next/src/libs/apolloClient.ts
@@ -16,7 +16,7 @@ import { schemaLink } from "./schemaLink.ts";
 
 export const APOLLO_STATE_PROP_NAME = "__APOLLO_STATE__";
 
-let apolloClient: ApolloClient<NormalizedCacheObject>;
+let apolloClient: ApolloClient;
 
 const errorLink = onError(({ graphQLErrors, networkError }) => {
   if (graphQLErrors)
@@ -64,7 +64,7 @@ export function initializeApollo(
   //  the initial state gets hydrated here
   if (initialState) {
     // Get existing cache, loaded during client side data fetching
-    const existingCache = _apolloClient.extract();
+    const existingCache = _apolloClient.extract() as NormalizedCacheObject;
 
     // Merge the initialState from getStaticProps/getServerSideProps
     // in the existing cache
@@ -92,20 +92,21 @@ interface ApolloProps {
 }
 
 export function addApolloState(
-  client: ApolloClient<NormalizedCacheObject>,
+  client: ApolloClient,
   pageProps: GetServerSidePropsResult<Partial<ApolloProps>> & {
     props: Partial<ApolloProps>;
   }
 ) {
   if (pageProps?.props) {
-    pageProps.props[APOLLO_STATE_PROP_NAME] = client.cache.extract();
+    pageProps.props[APOLLO_STATE_PROP_NAME] =
+      client.cache.extract() as NormalizedCacheObject;
   }
   return pageProps;
 }
 
 export function useApollo(pageProps?: ApolloProps) {
   const state = pageProps?.[APOLLO_STATE_PROP_NAME];
-  const storeRef = React.useRef<ApolloClient<NormalizedCacheObject>>();
+  const storeRef = React.useRef<ApolloClient>();
   if (!storeRef.current) {
     storeRef.current = initializeApollo(state);
   }
diff --git a/src/cache/core/cache.ts b/src/cache/core/cache.ts
--- a/src/cache/core/cache.ts
+++ b/src/cache/core/cache.ts
@@ -39,7 +39,7 @@ import type { Cache } from "./types/Cache.js";
 import type { MissingTree } from "./types/common.js";
 import type { DataProxy } from "./types/DataProxy.js";
 
-export type Transaction<T> = (c: ApolloCache<T>) => void;
+export type Transaction = (c: ApolloCache) => void;
 
 /**
  * Watched fragment options.
@@ -101,7 +101,7 @@ export type WatchFragmentResult<TData> =
       missing: MissingTree;
     };
 
-export abstract class ApolloCache<TSerialized> implements DataProxy {
+export abstract class ApolloCache implements DataProxy {
   public readonly assumeImmutableResults: boolean = false;
 
   // required to implement
@@ -148,14 +148,12 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
    * Called when hydrating a cache (server side rendering, or offline storage),
    * and also (potentially) during hot reloads.
    */
-  public abstract restore(
-    serializedState: TSerialized
-  ): ApolloCache<TSerialized>;
+  public abstract restore(serializedState: unknown): this;
 
   /**
    * Exposes the cache's complete state, in a serializable format for later restoration.
    */
-  public abstract extract(optimistic?: boolean): TSerialized;
+  public abstract extract(optimistic?: boolean): unknown;
 
   // Optimistic API
 
@@ -202,7 +200,7 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
   }
 
   public abstract performTransaction(
-    transaction: Transaction<TSerialized>,
+    transaction: Transaction,
     // Although subclasses may implement recordOptimisticTransaction
     // however they choose, the default implementation simply calls
     // performTransaction with a string as the second argument, allowing
@@ -214,7 +212,7 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
   ): void;
 
   public recordOptimisticTransaction(
-    transaction: Transaction<TSerialized>,
+    transaction: Transaction,
     optimisticId: string
   ) {
     this.performTransaction(transaction, optimisticId);
diff --git a/src/cache/core/types/Cache.ts b/src/cache/core/types/Cache.ts
--- a/src/cache/core/types/Cache.ts
+++ b/src/cache/core/types/Cache.ts
@@ -64,7 +64,7 @@ export namespace Cache {
   }
 
   export interface BatchOptions<
-    TCache extends ApolloCache<any>,
+    TCache extends ApolloCache,
     TUpdateResult = void,
   > {
     // Same as the first parameter of performTransaction, except the cache
diff --git a/src/cache/inmemory/inMemoryCache.ts b/src/cache/inmemory/inMemoryCache.ts
--- a/src/cache/inmemory/inMemoryCache.ts
+++ b/src/cache/inmemory/inMemoryCache.ts
@@ -42,7 +42,7 @@ type BroadcastOptions = Pick<
   "optimistic" | "onWatchUpdated"
 >;
 
-export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
+export class InMemoryCache extends ApolloCache {
   private data!: EntityStore;
   private optimisticData!: EntityStore;
 
diff --git a/src/cache/inmemory/reactiveVars.ts b/src/cache/inmemory/reactiveVars.ts
--- a/src/cache/inmemory/reactiveVars.ts
+++ b/src/cache/inmemory/reactiveVars.ts
@@ -8,25 +8,25 @@ import type { InMemoryCache } from "./inMemoryCache.js";
 export interface ReactiveVar<T> {
   (newValue?: T): T;
   onNextChange(listener: ReactiveListener<T>): () => void;
-  attachCache(cache: ApolloCache<any>): this;
-  forgetCache(cache: ApolloCache<any>): boolean;
+  attachCache(cache: ApolloCache): this;
+  forgetCache(cache: ApolloCache): boolean;
 }
 
 type ReactiveListener<T> = (value: T) => any;
 
 // Contextual Slot that acquires its value when custom read functions are
 // called in Policies#readField.
-export const cacheSlot = new Slot<ApolloCache<any>>();
+export const cacheSlot = new Slot<ApolloCache>();
 
 const cacheInfoMap = new WeakMap<
-  ApolloCache<any>,
+  ApolloCache,
   {
     vars: Set<ReactiveVar<any>>;
     dep: OptimisticDependencyFunction<ReactiveVar<any>>;
   }
 >();
 
-function getCacheInfo(cache: ApolloCache<any>) {
+function getCacheInfo(cache: ApolloCache) {
   let info = cacheInfoMap.get(cache)!;
   if (!info) {
     cacheInfoMap.set(
@@ -40,7 +40,7 @@ function getCacheInfo(cache: ApolloCache<any>) {
   return info;
 }
 
-export function forgetCache(cache: ApolloCache<any>) {
+export function forgetCache(cache: ApolloCache) {
   getCacheInfo(cache).vars.forEach((rv) => rv.forgetCache(cache));
 }
 
@@ -52,12 +52,12 @@ export function forgetCache(cache: ApolloCache<any>) {
 // garbage collected in the meantime, because it is no longer reachable,
 // you won't be able to call recallCache(cache), and the cache will
 // automatically disappear from the varsByCache WeakMap.
-export function recallCache(cache: ApolloCache<any>) {
+export function recallCache(cache: ApolloCache) {
   getCacheInfo(cache).vars.forEach((rv) => rv.attachCache(cache));
 }
 
 export function makeVar<T>(value: T): ReactiveVar<T> {
-  const caches = new Set<ApolloCache<any>>();
+  const caches = new Set<ApolloCache>();
   const listeners = new Set<ReactiveListener<T>>();
 
   const rv: ReactiveVar<T> = function (newValue) {
@@ -110,7 +110,7 @@ export function makeVar<T>(value: T): ReactiveVar<T> {
   return rv;
 }
 
-type Broadcastable = ApolloCache<any> & {
+type Broadcastable = ApolloCache & {
   // This method is protected in InMemoryCache, which we are ignoring, but
   // we still want some semblance of type safety when we call it.
   broadcastWatches?: InMemoryCache["broadcastWatches"];
diff --git a/src/cache/inmemory/types.ts b/src/cache/inmemory/types.ts
--- a/src/cache/inmemory/types.ts
+++ b/src/cache/inmemory/types.ts
@@ -106,7 +106,7 @@ export interface NormalizedCacheObject {
 export type OptimisticStoreItem = {
   id: string;
   data: NormalizedCacheObject;
-  transaction: Transaction<NormalizedCacheObject>;
+  transaction: Transaction;
 };
 
 export type ReadQueryOptions = {
diff --git a/src/core/ApolloClient.ts b/src/core/ApolloClient.ts
--- a/src/core/ApolloClient.ts
+++ b/src/core/ApolloClient.ts
@@ -69,7 +69,7 @@ interface DevtoolsOptions {
 
 let hasSuggestedDevtools = false;
 
-export interface ApolloClientOptions<TCacheShape> {
+export interface ApolloClientOptions {
   /**
    * The URI of the GraphQL endpoint that Apollo Client will communicate with.
    *
@@ -94,7 +94,7 @@ export interface ApolloClientOptions<TCacheShape> {
    *
    * For more information, see [Configuring the cache](https://www.apollographql.com/docs/react/caching/cache-configuration/).
    */
-  cache: ApolloCache<TCacheShape>;
+  cache: ApolloCache;
   /**
    * The time interval (in milliseconds) before Apollo Client force-fetches queries after a server-side render.
    *
@@ -175,21 +175,21 @@ export { mergeOptions };
  * receive results from the server and cache the results in a store. It also delivers updates
  * to GraphQL queries through `Observable` instances.
  */
-export class ApolloClient<TCacheShape> implements DataProxy {
+export class ApolloClient implements DataProxy {
   public link: ApolloLink;
-  public cache: ApolloCache<TCacheShape>;
+  public cache: ApolloCache;
   public disableNetworkFetches: boolean;
   public version: string;
   public queryDeduplication: boolean;
   public defaultOptions: DefaultOptions;
-  public readonly typeDefs: ApolloClientOptions<TCacheShape>["typeDefs"];
+  public readonly typeDefs: ApolloClientOptions["typeDefs"];
   public readonly devtoolsConfig: DevtoolsOptions;
 
-  private queryManager: QueryManager<TCacheShape>;
+  private queryManager: QueryManager;
   private devToolsHookCb?: Function;
   private resetStoreCallbacks: Array<() => Promise<any>> = [];
   private clearStoreCallbacks: Array<() => Promise<any>> = [];
-  private localState: LocalState<TCacheShape>;
+  private localState: LocalState;
 
   /**
    * Constructs an instance of `ApolloClient`.
@@ -217,7 +217,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
    * });
    * ```
    */
-  constructor(options: ApolloClientOptions<TCacheShape>) {
+  constructor(options: ApolloClientOptions) {
     if (!options.cache) {
       throw newInvariantError(
         "To initialize Apollo Client, you must specify a 'cache' property " +
@@ -330,11 +330,11 @@ export class ApolloClient<TCacheShape> implements DataProxy {
     }
 
     type DevToolsConnector = {
-      push(client: ApolloClient<any>): void;
+      push(client: ApolloClient): void;
     };
     const windowWithDevTools = window as Window & {
       [devtoolsSymbol]?: DevToolsConnector;
-      __APOLLO_CLIENT__?: ApolloClient<any>;
+      __APOLLO_CLIENT__?: ApolloClient;
     };
     const devtoolsSymbol = Symbol.for("apollo.devtools");
     (windowWithDevTools[devtoolsSymbol] =
@@ -483,7 +483,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
     TData = any,
     TVariables extends OperationVariables = OperationVariables,
     TContext extends Record<string, any> = DefaultContext,
-    TCache extends ApolloCache<any> = ApolloCache<any>,
+    TCache extends ApolloCache = ApolloCache,
   >(
     options: MutationOptions<TData, TVariables, TContext>
   ): Promise<FetchResult<MaybeMasked<TData>>> {
@@ -735,13 +735,13 @@ export class ApolloClient<TCacheShape> implements DataProxy {
    * active queries.
    */
   public refetchQueries<
-    TCache extends ApolloCache<any> = ApolloCache<TCacheShape>,
+    TCache extends ApolloCache = ApolloCache,
     TResult = Promise<ApolloQueryResult<any>>,
   >(
     options: RefetchQueriesOptions<TCache, TResult>
   ): RefetchQueriesResult<TResult> {
     const map = this.queryManager.refetchQueries(
-      options as RefetchQueriesOptions<ApolloCache<TCacheShape>, TResult>
+      options as RefetchQueriesOptions<ApolloCache, TResult>
     );
     const queries: ObservableQuery<any>[] = [];
     const results: InternalRefetchQueriesResult<TResult>[] = [];
@@ -793,7 +793,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
   /**
    * Exposes the cache's complete state, in a serializable format for later restoration.
    */
-  public extract(optimistic?: boolean): TCacheShape {
+  public extract(optimistic?: boolean) {
     return this.cache.extract(optimistic);
   }
 
@@ -804,7 +804,7 @@ export class ApolloClient<TCacheShape> implements DataProxy {
    * Called when hydrating a cache (server side rendering, or offline storage),
    * and also (potentially) during hot reloads.
    */
-  public restore(serializedState: TCacheShape): ApolloCache<TCacheShape> {
+  public restore(serializedState: unknown) {
     return this.cache.restore(serializedState);
   }
 
diff --git a/src/core/LocalState.ts b/src/core/LocalState.ts
--- a/src/core/LocalState.ts
+++ b/src/core/LocalState.ts
@@ -66,16 +66,16 @@ type ExecContext = {
   selectionsToResolve: Set<SelectionNode>;
 };
 
-type LocalStateOptions<TCacheShape> = {
-  cache: ApolloCache<TCacheShape>;
-  client?: ApolloClient<TCacheShape>;
+type LocalStateOptions = {
+  cache: ApolloCache;
+  client?: ApolloClient;
   resolvers?: Resolvers | Resolvers[];
   fragmentMatcher?: FragmentMatcher;
 };
 
-export class LocalState<TCacheShape> {
-  private cache: ApolloCache<TCacheShape>;
-  private client?: ApolloClient<TCacheShape>;
+export class LocalState {
+  private cache: ApolloCache;
+  private client?: ApolloClient;
   private resolvers?: Resolvers;
   private fragmentMatcher?: FragmentMatcher;
   private selectionsToResolveCache = new WeakMap<
@@ -88,7 +88,7 @@ export class LocalState<TCacheShape> {
     client,
     resolvers,
     fragmentMatcher,
-  }: LocalStateOptions<TCacheShape>) {
+  }: LocalStateOptions) {
     this.cache = cache;
 
     if (client) {
diff --git a/src/core/ObservableQuery.ts b/src/core/ObservableQuery.ts
--- a/src/core/ObservableQuery.ts
+++ b/src/core/ObservableQuery.ts
@@ -99,7 +99,7 @@ export class ObservableQuery<
   private initialResult: ApolloQueryResult<MaybeMasked<TData>>;
 
   private isTornDown: boolean;
-  private queryManager: QueryManager<any>;
+  private queryManager: QueryManager;
   private subscriptions = new Set<Subscription>();
 
   private waitForOwnResult: boolean;
@@ -123,7 +123,7 @@ export class ObservableQuery<
     queryInfo,
     options,
   }: {
-    queryManager: QueryManager<any>;
+    queryManager: QueryManager;
     queryInfo: QueryInfo;
     options: WatchQueryOptions<TVariables, TData>;
   }) {
diff --git a/src/core/QueryInfo.ts b/src/core/QueryInfo.ts
--- a/src/core/QueryInfo.ts
+++ b/src/core/QueryInfo.ts
@@ -24,10 +24,10 @@ export const enum CacheWriteBehavior {
   MERGE,
 }
 
-const destructiveMethodCounts = new WeakMap<ApolloCache<any>, number>();
+const destructiveMethodCounts = new WeakMap<ApolloCache, number>();
 
 function wrapDestructiveCacheMethod(
-  cache: ApolloCache<any>,
+  cache: ApolloCache,
   methodName: "evict" | "modify" | "reset"
 ) {
   const original = cache[methodName];
@@ -74,10 +74,10 @@ export class QueryInfo {
   variables?: Record<string, any>;
   stopped = false;
 
-  private cache: ApolloCache<any>;
+  private cache: ApolloCache;
 
   constructor(
-    queryManager: QueryManager<any>,
+    queryManager: QueryManager,
     public readonly queryId = queryManager.generateQueryId()
   ) {
     const cache = (this.cache = queryManager.cache);
diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts
--- a/src/core/QueryManager.ts
+++ b/src/core/QueryManager.ts
@@ -137,8 +137,8 @@ interface MaskOperationOptions<TData> {
   fetchPolicy?: WatchQueryFetchPolicy;
 }
 
-interface QueryManagerOptions<TStore> {
-  cache: ApolloCache<TStore>;
+interface QueryManagerOptions {
+  cache: ApolloCache;
   link: ApolloLink;
   defaultOptions: DefaultOptions;
   documentTransform: DocumentTransform | null | undefined;
@@ -146,14 +146,14 @@ interface QueryManagerOptions<TStore> {
   onBroadcast: undefined | (() => void);
   ssrMode: boolean;
   clientAwareness: Record<string, string>;
-  localState: LocalState<TStore>;
+  localState: LocalState;
   assumeImmutableResults: boolean;
   defaultContext: Partial<DefaultContext> | undefined;
   dataMasking: boolean;
 }
 
-export class QueryManager<TStore> {
-  public cache: ApolloCache<TStore>;
+export class QueryManager {
+  public cache: ApolloCache;
   public link: ApolloLink;
   public defaultOptions: DefaultOptions;
 
@@ -165,7 +165,7 @@ export class QueryManager<TStore> {
 
   private queryDeduplication: boolean;
   private clientAwareness: Record<string, string> = {};
-  private localState: LocalState<TStore>;
+  private localState: LocalState;
 
   private onBroadcast?: () => void;
   public mutationStore?: {
@@ -182,7 +182,7 @@ export class QueryManager<TStore> {
   // @apollo/experimental-nextjs-app-support can access type info.
   protected fetchCancelFns = new Map<string, (error: any) => any>();
 
-  constructor(options: QueryManagerOptions<TStore>) {
+  constructor(options: QueryManagerOptions) {
     const defaultDocumentTransform = new DocumentTransform(
       (document) => this.cache.transformDocument(document),
       // Allow the apollo cache to manage its own transform caches
@@ -239,7 +239,7 @@ export class QueryManager<TStore> {
     TData,
     TVariables extends OperationVariables,
     TContext extends Record<string, any>,
-    TCache extends ApolloCache<any>,
+    TCache extends ApolloCache,
   >({
     mutation,
     variables,
@@ -413,7 +413,7 @@ export class QueryManager<TStore> {
     TData,
     TVariables,
     TContext,
-    TCache extends ApolloCache<any>,
+    TCache extends ApolloCache,
   >(
     mutation: {
       mutationId: string;
@@ -624,7 +624,7 @@ export class QueryManager<TStore> {
     TData,
     TVariables,
     TContext,
-    TCache extends ApolloCache<any>,
+    TCache extends ApolloCache,
   >(
     optimisticResponse: any,
     mutation: {
@@ -1106,7 +1106,7 @@ export class QueryManager<TStore> {
     this.queries.forEach((info) => info.notify());
   }
 
-  public getLocalState(): LocalState<TStore> {
+  public getLocalState() {
     return this.localState;
   }
 
@@ -1399,7 +1399,7 @@ export class QueryManager<TStore> {
     removeOptimistic = optimistic ? makeUniqueId("refetchQueries") : void 0,
     onQueryUpdated,
   }: InternalRefetchQueriesOptions<
-    ApolloCache<TStore>,
+    ApolloCache,
     TResult
   >): InternalRefetchQueriesMap<TResult> {
     const includedQueriesById = new Map<
diff --git a/src/core/types.ts b/src/core/types.ts
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -79,10 +79,7 @@ export type InternalRefetchQueriesInclude =
 
 // Used by ApolloClient["refetchQueries"]
 // TODO Improve documentation comments for this public type.
-export interface RefetchQueriesOptions<
-  TCache extends ApolloCache<any>,
-  TResult,
-> {
+export interface RefetchQueriesOptions<TCache extends ApolloCache, TResult> {
   updateCache?: (cache: TCache) => void;
   // The client.refetchQueries method discourages passing QueryOptions, by
   // restricting the public type of options.include to exclude QueryOptions as
@@ -142,7 +139,7 @@ export interface RefetchQueriesResult<TResult>
 
 // Used by QueryManager["refetchQueries"]
 export interface InternalRefetchQueriesOptions<
-  TCache extends ApolloCache<any>,
+  TCache extends ApolloCache,
   TResult,
 > extends Omit<RefetchQueriesOptions<TCache, TResult>, "include"> {
   // Just like the refetchQueries option for a mutation, an array of strings,
@@ -214,7 +211,7 @@ export type MutationUpdaterFn<T = { [key: string]: any }> = (
   // The MutationUpdaterFn type is broken because it mistakenly uses the same
   // type parameter T for both the cache and the mutationResult. Do not use this
   // type unless you absolutely need it for backwards compatibility.
-  cache: ApolloCache<T>,
+  cache: ApolloCache,
   mutationResult: FetchResult<T>
 ) => void;
 
@@ -222,7 +219,7 @@ export type MutationUpdaterFunction<
   TData,
   TVariables,
   TContext,
-  TCache extends ApolloCache<any>,
+  TCache extends ApolloCache,
 > = (
   cache: TCache,
   result: Omit<FetchResult<Unmasked<TData>>, "context">,
diff --git a/src/core/watchQueryOptions.ts b/src/core/watchQueryOptions.ts
--- a/src/core/watchQueryOptions.ts
+++ b/src/core/watchQueryOptions.ts
@@ -270,7 +270,7 @@ interface MutationBaseOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > {
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#optimisticResponse:member} */
   optimisticResponse?:
@@ -311,7 +311,7 @@ export interface MutationOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > extends MutationSharedOptions<TData, TVariables, TContext, TCache> {
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#mutation:member} */
   mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
@@ -320,7 +320,7 @@ export interface MutationSharedOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > extends MutationBaseOptions<TData, TVariables, TContext, TCache> {
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#fetchPolicy:member} */
   fetchPolicy?: MutationFetchPolicy;
diff --git a/src/masking/maskDefinition.ts b/src/masking/maskDefinition.ts
--- a/src/masking/maskDefinition.ts
+++ b/src/masking/maskDefinition.ts
@@ -17,7 +17,7 @@ interface MaskingContext {
   operationType: "query" | "mutation" | "subscription" | "fragment";
   operationName: string | undefined;
   fragmentMap: FragmentMap;
-  cache: ApolloCache<unknown>;
+  cache: ApolloCache;
   mutableTargets: WeakMap<any, any>;
   knownChanged: WeakSet<any>;
 }
diff --git a/src/masking/maskFragment.ts b/src/masking/maskFragment.ts
--- a/src/masking/maskFragment.ts
+++ b/src/masking/maskFragment.ts
@@ -21,7 +21,7 @@ import { warnOnImproperCacheImplementation } from "./utils.js";
 export function maskFragment<TData = unknown>(
   data: TData,
   document: TypedDocumentNode<TData> | DocumentNode,
-  cache: ApolloCache<unknown>,
+  cache: ApolloCache,
   fragmentName?: string
 ): TData {
   if (!cache.fragmentMatches) {
diff --git a/src/masking/maskOperation.ts b/src/masking/maskOperation.ts
--- a/src/masking/maskOperation.ts
+++ b/src/masking/maskOperation.ts
@@ -18,7 +18,7 @@ import { warnOnImproperCacheImplementation } from "./utils.js";
 export function maskOperation<TData = unknown>(
   data: TData,
   document: DocumentNode | TypedDocumentNode<TData>,
-  cache: ApolloCache<unknown>
+  cache: ApolloCache
 ): TData {
   if (!cache.fragmentMatches) {
     if (__DEV__) {
diff --git a/src/react/context/ApolloContext.ts b/src/react/context/ApolloContext.ts
--- a/src/react/context/ApolloContext.ts
+++ b/src/react/context/ApolloContext.ts
@@ -6,7 +6,7 @@ import type { RenderPromises } from "@apollo/client/react/ssr";
 import { invariant } from "@apollo/client/utilities/invariant";
 
 export interface ApolloContextValue {
-  client?: ApolloClient<object>;
+  client?: ApolloClient;
   renderPromises?: RenderPromises;
 }
 
diff --git a/src/react/hooks/internal/wrapHook.ts b/src/react/hooks/internal/wrapHook.ts
--- a/src/react/hooks/internal/wrapHook.ts
+++ b/src/react/hooks/internal/wrapHook.ts
@@ -37,7 +37,7 @@ export type HookWrappers = {
   ) => WrappableHooks[K];
 };
 
-interface QueryManagerWithWrappers<T> extends QueryManager<T> {
+interface QueryManagerWithWrappers extends QueryManager {
   [wrapperSymbol]?: HookWrappers;
 }
 
@@ -79,13 +79,13 @@ interface QueryManagerWithWrappers<T> extends QueryManager<T> {
 export function wrapHook<Hook extends (...args: any[]) => any>(
   hookName: keyof WrappableHooks,
   useHook: Hook,
-  clientOrObsQuery: ObservableQuery<any> | ApolloClient<any>
+  clientOrObsQuery: ObservableQuery<any> | ApolloClient
 ): Hook {
   const queryManager = (
     clientOrObsQuery as unknown as {
       // both `ApolloClient` and `ObservableQuery` have a `queryManager` property
       // but they're both `private`, so we have to cast around for a bit here.
-      queryManager: QueryManagerWithWrappers<any>;
+      queryManager: QueryManagerWithWrappers;
     }
   )["queryManager"];
   const wrappers = queryManager && queryManager[wrapperSymbol];
diff --git a/src/react/hooks/useApolloClient.ts b/src/react/hooks/useApolloClient.ts
--- a/src/react/hooks/useApolloClient.ts
+++ b/src/react/hooks/useApolloClient.ts
@@ -19,9 +19,7 @@ import { invariant } from "@apollo/client/utilities/invariant";
  * @since 3.0.0
  * @returns The `ApolloClient` instance being used by the application.
  */
-export function useApolloClient(
-  override?: ApolloClient<object>
-): ApolloClient<object> {
+export function useApolloClient(override?: ApolloClient): ApolloClient {
   const context = React.useContext(getApolloContext());
   const client = override || context.client;
   invariant(
diff --git a/src/react/hooks/useFragment.ts b/src/react/hooks/useFragment.ts
--- a/src/react/hooks/useFragment.ts
+++ b/src/react/hooks/useFragment.ts
@@ -36,7 +36,7 @@ export interface UseFragmentOptions<TData, TVars>
    *
    * @docGroup 1. Operation options
    */
-  client?: ApolloClient<any>;
+  client?: ApolloClient;
 }
 
 // TODO: Update this to return `null` when there is no data returned from the
diff --git a/src/react/hooks/useLazyQuery.ts b/src/react/hooks/useLazyQuery.ts
--- a/src/react/hooks/useLazyQuery.ts
+++ b/src/react/hooks/useLazyQuery.ts
@@ -73,7 +73,7 @@ export interface LazyQueryHookOptions<
   skipPollAttempt?: () => boolean;
 
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */
-  client?: ApolloClient<any>;
+  client?: ApolloClient;
 
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */
   context?: DefaultContext;
@@ -117,7 +117,7 @@ export interface LazyQueryResult<TData, TVariables extends OperationVariables> {
     }
   ) => Promise<ApolloQueryResult<MaybeMasked<TFetchData>>>;
   /** {@inheritDoc @apollo/client!QueryResultDocumentation#client:member} */
-  client: ApolloClient<any>;
+  client: ApolloClient;
   /** {@inheritDoc @apollo/client!QueryResultDocumentation#observable:member} */
   observable: ObservableQuery<TData, TVariables>;
   /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */
diff --git a/src/react/hooks/useMutation.ts b/src/react/hooks/useMutation.ts
--- a/src/react/hooks/useMutation.ts
+++ b/src/react/hooks/useMutation.ts
@@ -74,7 +74,7 @@ export function useMutation<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 >(
   mutation: DocumentNode | TypedDocumentNode<TData, TVariables>,
   options?: MutationHookOptions<
diff --git a/src/react/hooks/useQuery.ts b/src/react/hooks/useQuery.ts
--- a/src/react/hooks/useQuery.ts
+++ b/src/react/hooks/useQuery.ts
@@ -148,7 +148,7 @@ function useInternalState<
   TData = any,
   TVariables extends OperationVariables = OperationVariables,
 >(
-  client: ApolloClient<object>,
+  client: ApolloClient,
   query: DocumentNode | TypedDocumentNode<any, any>,
   options: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>,
   renderPromises: RenderPromises | undefined,
@@ -258,7 +258,7 @@ function useObservableSubscriptionResult<
 >(
   resultData: InternalResult<TData, TVariables>,
   observable: ObservableQuery<TData, TVariables>,
-  client: ApolloClient<object>,
+  client: ApolloClient,
   options: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>,
   watchQueryOptions: Readonly<WatchQueryOptions<TVariables, TData>>,
   disableNetworkFetches: boolean,
@@ -381,7 +381,7 @@ function useResubscribeIfNecessary<
   resultData: InternalResult<TData, TVariables>,
   /** this hook will mutate properties on `observable` */
   observable: ObsQueryWithMeta<TData, TVariables>,
-  client: ApolloClient<object>,
+  client: ApolloClient,
   options: QueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>,
   watchQueryOptions: Readonly<WatchQueryOptions<TVariables, TData>>
 ) {
@@ -420,7 +420,7 @@ function createMakeWatchQueryOptions<
   TData = any,
   TVariables extends OperationVariables = OperationVariables,
 >(
-  client: ApolloClient<object>,
+  client: ApolloClient,
   query: DocumentNode | TypedDocumentNode<TData, TVariables>,
   {
     skip,
@@ -476,7 +476,7 @@ function createMakeWatchQueryOptions<
 
 function getObsQueryOptions<TData, TVariables extends OperationVariables>(
   observable: ObservableQuery<TData, TVariables> | undefined,
-  client: ApolloClient<object>,
+  client: ApolloClient,
   queryHookOptions: QueryHookOptions<TData, TVariables>,
   watchQueryOptions: Partial<WatchQueryOptions<TVariables, TData>>
 ): WatchQueryOptions<TVariables, TData> {
@@ -508,7 +508,7 @@ function setResult<TData, TVariables extends OperationVariables>(
   nextResult: ApolloQueryResult<MaybeMasked<TData>>,
   resultData: InternalResult<TData, TVariables>,
   observable: ObservableQuery<TData, TVariables>,
-  client: ApolloClient<object>,
+  client: ApolloClient,
   forceUpdate: () => void
 ) {
   const previousResult = resultData.current;
@@ -530,7 +530,7 @@ function setResult<TData, TVariables extends OperationVariables>(
 function getCurrentResult<TData, TVariables extends OperationVariables>(
   resultData: InternalResult<TData, TVariables>,
   observable: ObservableQuery<TData, TVariables>,
-  client: ApolloClient<object>
+  client: ApolloClient
 ): InternalQueryResult<TData, TVariables> {
   // Using this.result as a cache ensures getCurrentResult continues returning
   // the same (===) result object, unless state.setResult has been called, or
@@ -562,7 +562,7 @@ function toQueryResult<TData, TVariables extends OperationVariables>(
   result: ApolloQueryResult<MaybeMasked<TData>>,
   previousData: MaybeMasked<TData> | undefined,
   observable: ObservableQuery<TData, TVariables>,
-  client: ApolloClient<object>
+  client: ApolloClient
 ): InternalQueryResult<TData, TVariables> {
   const { data, partial, ...resultWithoutPartial } = result;
   const queryResult: InternalQueryResult<TData, TVariables> = {
diff --git a/src/react/hooks/useQueryRefHandlers.ts b/src/react/hooks/useQueryRefHandlers.ts
--- a/src/react/hooks/useQueryRefHandlers.ts
+++ b/src/react/hooks/useQueryRefHandlers.ts
@@ -62,7 +62,7 @@ export function useQueryRefHandlers<
       // return any truthy value that is passed in as an override so we cast the result
       (unwrapped["observable"] as any)
     : undefined
-  ) as ApolloClient<any> | ObservableQuery<TData>;
+  ) as ApolloClient | ObservableQuery<TData>;
 
   return wrapHook(
     "useQueryRefHandlers",
diff --git a/src/react/hooks/useReadQuery.ts b/src/react/hooks/useReadQuery.ts
--- a/src/react/hooks/useReadQuery.ts
+++ b/src/react/hooks/useReadQuery.ts
@@ -54,7 +54,7 @@ export function useReadQuery<TData>(
       // return any truthy value that is passed in as an override so we cast the result
       (unwrapped["observable"] as any)
     : undefined
-  ) as ApolloClient<any> | ObservableQuery<TData>;
+  ) as ApolloClient | ObservableQuery<TData>;
 
   return wrapHook(
     "useReadQuery",
diff --git a/src/react/hooks/useSubscription.ts b/src/react/hooks/useSubscription.ts
--- a/src/react/hooks/useSubscription.ts
+++ b/src/react/hooks/useSubscription.ts
@@ -320,7 +320,7 @@ function createSubscription<
   TData = any,
   TVariables extends OperationVariables = OperationVariables,
 >(
-  client: ApolloClient<any>,
+  client: ApolloClient,
   query: TypedDocumentNode<TData, TVariables>,
   variables: TVariables | undefined,
   fetchPolicy: FetchPolicy | undefined,
diff --git a/src/react/hooks/useSuspenseFragment.ts b/src/react/hooks/useSuspenseFragment.ts
--- a/src/react/hooks/useSuspenseFragment.ts
+++ b/src/react/hooks/useSuspenseFragment.ts
@@ -55,7 +55,7 @@ export type UseSuspenseFragmentOptions<
    *
    * @docGroup 1. Operation options
    */
-  client?: ApolloClient<any>;
+  client?: ApolloClient;
 } & VariablesOption<NoInfer<TVariables>>;
 
 export type UseSuspenseFragmentResult<TData> = { data: MaybeMasked<TData> };
diff --git a/src/react/hooks/useSuspenseQuery.ts b/src/react/hooks/useSuspenseQuery.ts
--- a/src/react/hooks/useSuspenseQuery.ts
+++ b/src/react/hooks/useSuspenseQuery.ts
@@ -36,7 +36,7 @@ export interface UseSuspenseQueryResult<
   TData = unknown,
   TVariables extends OperationVariables = OperationVariables,
 > {
-  client: ApolloClient<any>;
+  client: ApolloClient;
   data: MaybeMasked<TData>;
   error: ErrorLike | undefined;
   fetchMore: FetchMoreFunction<TData, TVariables>;
@@ -338,7 +338,7 @@ interface UseWatchQueryOptionsHookOptions<
   TData,
   TVariables extends OperationVariables,
 > {
-  client: ApolloClient<unknown>;
+  client: ApolloClient;
   query: DocumentNode | TypedDocumentNode<TData, TVariables>;
   options: SkipToken | SuspenseQueryHookOptions<TData, TVariables>;
 }
diff --git a/src/react/internal/cache/FragmentReference.ts b/src/react/internal/cache/FragmentReference.ts
--- a/src/react/internal/cache/FragmentReference.ts
+++ b/src/react/internal/cache/FragmentReference.ts
@@ -41,7 +41,7 @@ export class FragmentReference<
   private references = 0;
 
   constructor(
-    client: ApolloClient<any>,
+    client: ApolloClient,
     watchFragmentOptions: WatchFragmentOptions<TData, TVariables> & {
       from: string;
     },
@@ -173,7 +173,7 @@ export class FragmentReference<
   }
 
   private getDiff<TData, TVariables>(
-    client: ApolloClient<any>,
+    client: ApolloClient,
     options: WatchFragmentOptions<TData, TVariables> & { from: string }
   ) {
     const { cache } = client;
diff --git a/src/react/internal/cache/SuspenseCache.ts b/src/react/internal/cache/SuspenseCache.ts
--- a/src/react/internal/cache/SuspenseCache.ts
+++ b/src/react/internal/cache/SuspenseCache.ts
@@ -56,7 +56,7 @@ export class SuspenseCache {
 
   getFragmentRef<TData, TVariables>(
     cacheKey: FragmentCacheKey,
-    client: ApolloClient<any>,
+    client: ApolloClient,
     options: WatchFragmentOptions<TData, TVariables> & { from: string }
   ) {
     const ref = this.fragmentRefs.lookupArray(cacheKey) as {
diff --git a/src/react/internal/cache/getSuspenseCache.ts b/src/react/internal/cache/getSuspenseCache.ts
--- a/src/react/internal/cache/getSuspenseCache.ts
+++ b/src/react/internal/cache/getSuspenseCache.ts
@@ -14,7 +14,7 @@ declare module "@apollo/client/core" {
 const suspenseCacheSymbol = Symbol.for("apollo.suspenseCache");
 
 export function getSuspenseCache(
-  client: ApolloClient<object> & {
+  client: ApolloClient & {
     [suspenseCacheSymbol]?: SuspenseCache;
   }
 ) {
diff --git a/src/react/query-preloader/createQueryPreloader.ts b/src/react/query-preloader/createQueryPreloader.ts
--- a/src/react/query-preloader/createQueryPreloader.ts
+++ b/src/react/query-preloader/createQueryPreloader.ts
@@ -153,7 +153,7 @@ export interface PreloadQueryFunction {
  * @since 3.9.0
  */
 export function createQueryPreloader(
-  client: ApolloClient<any>
+  client: ApolloClient
 ): PreloadQueryFunction {
   return wrapHook(
     "createQueryPreloader",
diff --git a/src/react/types/types.ts b/src/react/types/types.ts
--- a/src/react/types/types.ts
+++ b/src/react/types/types.ts
@@ -43,7 +43,7 @@ export type {
 export type { DefaultContext as Context } from "../../core/index.js";
 
 export type CommonOptions<TOptions> = TOptions & {
-  client?: ApolloClient<object>;
+  client?: ApolloClient;
 };
 
 /* Query types */
@@ -55,7 +55,7 @@ export interface BaseQueryOptions<
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#ssr:member} */
   ssr?: boolean;
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */
-  client?: ApolloClient<any>;
+  client?: ApolloClient;
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */
   context?: DefaultContext;
 }
@@ -120,7 +120,7 @@ export interface QueryResult<
   TVariables extends OperationVariables = OperationVariables,
 > extends ObservableQueryFields<TData, TVariables> {
   /** {@inheritDoc @apollo/client!QueryResultDocumentation#client:member} */
-  client: ApolloClient<any>;
+  client: ApolloClient;
   /** {@inheritDoc @apollo/client!QueryResultDocumentation#observable:member} */
   observable: ObservableQuery<TData, TVariables>;
   /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */
@@ -161,7 +161,7 @@ export interface SuspenseQueryHookOptions<
   TVariables extends OperationVariables = OperationVariables,
 > {
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */
-  client?: ApolloClient<any>;
+  client?: ApolloClient;
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */
   context?: DefaultContext;
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#variables:member} */
@@ -230,7 +230,7 @@ export type LoadableQueryHookFetchPolicy = Extract<
 
 export interface LoadableQueryHookOptions {
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */
-  client?: ApolloClient<any>;
+  client?: ApolloClient;
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */
   context?: DefaultContext;
   /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */
@@ -255,10 +255,10 @@ export interface BaseMutationOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > extends MutationSharedOptions<TData, TVariables, TContext, TCache> {
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#client:member} */
-  client?: ApolloClient<object>;
+  client?: ApolloClient;
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#notifyOnNetworkStatusChange:member} */
   notifyOnNetworkStatusChange?: boolean;
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#onCompleted:member} */
@@ -274,7 +274,7 @@ export interface MutationFunctionOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > extends BaseMutationOptions<TData, TVariables, TContext, TCache> {
   /** {@inheritDoc @apollo/client!MutationOptionsDocumentation#mutation:member} */
   mutation?: DocumentNode | TypedDocumentNode<TData, TVariables>;
@@ -290,7 +290,7 @@ export interface MutationResult<TData = any> {
   /** {@inheritDoc @apollo/client!MutationResultDocumentation#called:member} */
   called: boolean;
   /** {@inheritDoc @apollo/client!MutationResultDocumentation#client:member} */
-  client: ApolloClient<object>;
+  client: ApolloClient;
   /** {@inheritDoc @apollo/client!MutationResultDocumentation#reset:member} */
   reset: () => void;
 }
@@ -299,7 +299,7 @@ export declare type MutationFunction<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > = (
   options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>
 ) => Promise<FetchResult<MaybeMasked<TData>>>;
@@ -308,14 +308,14 @@ export interface MutationHookOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > extends BaseMutationOptions<TData, TVariables, TContext, TCache> {}
 
 export interface MutationDataOptions<
   TData = any,
   TVariables = OperationVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > extends BaseMutationOptions<TData, TVariables, TContext, TCache> {
   mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
 }
@@ -324,7 +324,7 @@ export type MutationTuple<
   TData,
   TVariables,
   TContext = DefaultContext,
-  TCache extends ApolloCache<any> = ApolloCache<any>,
+  TCache extends ApolloCache = ApolloCache,
 > = [
   mutate: (
     options?: MutationFunctionOptions<TData, TVariables, TContext, TCache>
@@ -337,12 +337,12 @@ export type MutationTuple<
 /* Subscription types */
 
 export interface OnDataOptions<TData = any> {
-  client: ApolloClient<object>;
+  client: ApolloClient;
   data: SubscriptionResult<TData>;
 }
 
 export interface OnSubscriptionDataOptions<TData = any> {
-  client: ApolloClient<object>;
+  client: ApolloClient;
   subscriptionData: SubscriptionResult<TData>;
 }
 
@@ -361,7 +361,7 @@ export interface BaseSubscriptionOptions<
     | boolean
     | ((options: BaseSubscriptionOptions<TData, TVariables>) => boolean);
   /** {@inheritDoc @apollo/client!SubscriptionOptionsDocumentation#client:member} */
-  client?: ApolloClient<object>;
+  client?: ApolloClient;
   /** {@inheritDoc @apollo/client!SubscriptionOptionsDocumentation#skip:member} */
   skip?: boolean;
   /** {@inheritDoc @apollo/client!SubscriptionOptionsDocumentation#context:member} */
diff --git a/src/utilities/internal/getMemoryInternals.ts b/src/utilities/internal/getMemoryInternals.ts
--- a/src/utilities/internal/getMemoryInternals.ts
+++ b/src/utilities/internal/getMemoryInternals.ts
@@ -131,7 +131,7 @@ function getCurrentCacheSizes() {
   );
 }
 
-function _getApolloClientMemoryInternals(this: ApolloClient<any>) {
+function _getApolloClientMemoryInternals(this: ApolloClient) {
   if (!__DEV__) throw new Error("only supported in development mode");
 
   return {
@@ -155,7 +155,7 @@ function _getApolloClientMemoryInternals(this: ApolloClient<any>) {
   };
 }
 
-function _getApolloCacheMemoryInternals(this: ApolloCache<any>) {
+function _getApolloCacheMemoryInternals(this: ApolloCache) {
   return {
     cache: {
       fragmentQueryDocuments: getWrapperInformation(this["getFragmentDoc"]),


Test patch:
diff --git a/src/__tests__/client.ts b/src/__tests__/client.ts
--- a/src/__tests__/client.ts
+++ b/src/__tests__/client.ts
@@ -15,6 +15,7 @@ import {
   createFragmentRegistry,
   InMemoryCache,
   makeVar,
+  NormalizedCacheObject,
   PossibleTypesMap,
 } from "@apollo/client/cache";
 import {
@@ -3735,7 +3736,7 @@ describe("custom document transforms", () => {
       ],
     });
 
-    const cache = client.cache.extract();
+    const cache = client.cache.extract() as NormalizedCacheObject;
 
     expect(cache["Dog:1"]).toEqual({
       id: 1,
@@ -4227,7 +4228,7 @@ describe("custom document transforms", () => {
       },
     });
 
-    const cache = client.cache.extract();
+    const cache = client.cache.extract() as NormalizedCacheObject;
 
     expect(cache["User:1"]).toEqual({
       __typename: "User",
@@ -4458,7 +4459,7 @@ describe("custom document transforms", () => {
       },
     });
 
-    const cache = client.cache.extract();
+    const cache = client.cache.extract() as NormalizedCacheObject;
 
     expect(cache["Profile:1"]).toEqual({
       __typename: "Profile",
diff --git a/src/__tests__/dataMasking.ts b/src/__tests__/dataMasking.ts
--- a/src/__tests__/dataMasking.ts
+++ b/src/__tests__/dataMasking.ts
@@ -5888,7 +5888,7 @@ describe("client.mutate", () => {
   });
 });
 
-class TestCache extends ApolloCache<unknown> {
+class TestCache extends ApolloCache {
   public diff<T>(query: Cache.DiffOptions): DataProxy.DiffResult<T> {
     return { result: null, complete: false };
   }
@@ -5901,9 +5901,7 @@ class TestCache extends ApolloCache<unknown> {
     return undefined;
   }
 
-  public performTransaction(
-    transaction: <TSerialized>(c: ApolloCache<TSerialized>) => void
-  ): void {
+  public performTransaction(transaction: (c: ApolloCache) => void): void {
     transaction(this);
   }
 
@@ -5919,7 +5917,7 @@ class TestCache extends ApolloCache<unknown> {
     return new Promise<void>(() => null);
   }
 
-  public restore(serializedState: unknown): ApolloCache<unknown> {
+  public restore(serializedState: unknown): this {
     return this;
   }
 
diff --git a/src/__tests__/fetchMore.ts b/src/__tests__/fetchMore.ts
--- a/src/__tests__/fetchMore.ts
+++ b/src/__tests__/fetchMore.ts
@@ -519,7 +519,7 @@ describe("fetchMore on an observable query", () => {
     `;
 
     function makeClient(): {
-      client: ApolloClient<any>;
+      client: ApolloClient;
       linkRequests: Array<{
         operationName: string;
         offset: number;
@@ -573,7 +573,7 @@ describe("fetchMore on an observable query", () => {
       };
     }
 
-    function checkCacheExtract1234678(cache: ApolloCache<any>) {
+    function checkCacheExtract1234678(cache: ApolloCache) {
       expect(cache.extract()).toEqual({
         ROOT_QUERY: {
           __typename: "Query",
diff --git a/src/__tests__/local-state/general.ts b/src/__tests__/local-state/general.ts
--- a/src/__tests__/local-state/general.ts
+++ b/src/__tests__/local-state/general.ts
@@ -343,7 +343,7 @@ describe("Cache manipulation", () => {
         start: (
           _1: any,
           variables: { field: string },
-          { cache }: { cache: ApolloCache<any> }
+          { cache }: { cache: ApolloCache }
         ) => {
           cache.writeQuery({ query, data: { field: variables.field } });
           return {
@@ -582,7 +582,7 @@ describe("Sample apps", () => {
       return (
         _result: {},
         variables: { amount: number },
-        { cache }: { cache: ApolloCache<any> }
+        { cache }: { cache: ApolloCache }
       ): null => {
         const read = client.readQuery<{ count: number }>({
           query,
@@ -669,7 +669,7 @@ describe("Sample apps", () => {
       return (
         _result: {},
         variables: Todo,
-        { cache }: { cache: ApolloCache<any> }
+        { cache }: { cache: ApolloCache }
       ): null => {
         const data = updater(client.readQuery({ query, variables }), variables);
         cache.writeQuery({ query, variables, data });
diff --git a/src/__tests__/optimistic.ts b/src/__tests__/optimistic.ts
--- a/src/__tests__/optimistic.ts
+++ b/src/__tests__/optimistic.ts
@@ -3,7 +3,11 @@ import { assign, cloneDeep } from "lodash";
 import { firstValueFrom, from, lastValueFrom, Observable } from "rxjs";
 import { map, take, toArray } from "rxjs/operators";
 
-import { Cache, InMemoryCache } from "@apollo/client/cache";
+import {
+  Cache,
+  InMemoryCache,
+  NormalizedCacheObject,
+} from "@apollo/client/cache";
 import {
   ApolloCache,
   ApolloClient,
@@ -19,7 +23,6 @@ import {
 } from "@apollo/client/testing";
 import { addTypenameToDocument } from "@apollo/client/utilities";
 
-import { QueryManager } from "../core/QueryManager.js";
 import { ObservableStream } from "../testing/internal/index.js";
 
 describe("optimistic mutation results", () => {
@@ -228,7 +231,9 @@ describe("optimistic mutation results", () => {
         });
 
         {
-          const dataInStore = client.cache.extract(true);
+          const dataInStore = client.cache.extract(
+            true
+          ) as NormalizedCacheObject;
           expect((dataInStore["TodoList5"] as any).todos.length).toBe(4);
           expect((dataInStore["Todo99"] as any).text).toBe(
             "Optimistically generated"
@@ -240,7 +245,9 @@ describe("optimistic mutation results", () => {
         );
 
         {
-          const dataInStore = client.cache.extract(true);
+          const dataInStore = client.cache.extract(
+            true
+          ) as NormalizedCacheObject;
           expect((dataInStore["TodoList5"] as any).todos.length).toBe(3);
           expect(dataInStore).not.toHaveProperty("Todo99");
         }
@@ -345,7 +352,7 @@ describe("optimistic mutation results", () => {
 
         await expect(stream).toEmitNext();
 
-        const queryManager: QueryManager<any> = (client as any).queryManager;
+        const queryManager = client["queryManager"];
 
         const promise = client
           .mutate({
@@ -919,7 +926,9 @@ describe("optimistic mutation results", () => {
         "todos" in initialList &&
         Array.isArray(initialList.todos);
 
-      const initialList = client.cache.extract(true)[id];
+      const initialList = (client.cache.extract(true) as NormalizedCacheObject)[
+        id
+      ];
 
       if (!isTodoList(initialList)) {
         throw new Error("Expected TodoList");
@@ -960,7 +969,7 @@ describe("optimistic mutation results", () => {
         },
       });
 
-      const list = client.cache.extract(true)[id];
+      const list = (client.cache.extract(true) as NormalizedCacheObject)[id];
 
       if (!isTodoList(list)) {
         throw new Error("Expected TodoList");
@@ -1910,7 +1919,7 @@ describe("optimistic mutation results", () => {
       type Item = ReturnType<typeof makeItem>;
       type Data = { items: Item[] };
 
-      function append(cache: ApolloCache<any>, item: Item) {
+      function append(cache: ApolloCache, item: Item) {
         const data = cache.readQuery<Data>({ query });
         cache.writeQuery({
           query,
diff --git a/src/__tests__/resultCacheCleaning.ts b/src/__tests__/resultCacheCleaning.ts
--- a/src/__tests__/resultCacheCleaning.ts
+++ b/src/__tests__/resultCacheCleaning.ts
@@ -1,6 +1,6 @@
 import { makeExecutableSchema } from "@graphql-tools/schema";
 
-import { InMemoryCache, NormalizedCacheObject } from "@apollo/client/cache";
+import { InMemoryCache } from "@apollo/client/cache";
 import { ApolloClient, gql, Resolvers } from "@apollo/client/core";
 import { SchemaLink } from "@apollo/client/link/schema";
 
@@ -135,7 +135,7 @@ describe("resultCache cleaning", () => {
     },
   };
 
-  let client: ApolloClient<NormalizedCacheObject>;
+  let client: ApolloClient;
 
   beforeEach(() => {
     client = new ApolloClient({
diff --git a/src/cache/core/__tests__/cache.ts b/src/cache/core/__tests__/cache.ts
--- a/src/cache/core/__tests__/cache.ts
+++ b/src/cache/core/__tests__/cache.ts
@@ -6,7 +6,7 @@ import { Cache, DataProxy } from "@apollo/client/cache";
 import { Reference } from "../../../utilities/graphql/storeUtils.js";
 import { ApolloCache } from "../cache.js";
 
-class TestCache extends ApolloCache<unknown> {
+class TestCache extends ApolloCache {
   constructor() {
     super();
   }
@@ -23,9 +23,7 @@ class TestCache extends ApolloCache<unknown> {
     return undefined;
   }
 
-  public performTransaction(
-    transaction: <TSerialized>(c: ApolloCache<TSerialized>) => void
-  ): void {
+  public performTransaction(transaction: (c: ApolloCache) => void): void {
     transaction(this);
   }
 
@@ -36,7 +34,7 @@ class TestCache extends ApolloCache<unknown> {
   }
 
   public recordOptimisticTransaction(
-    transaction: <TSerialized>(c: ApolloCache<TSerialized>) => void,
+    transaction: (c: ApolloCache) => void,
     id: string
   ): void {}
 
@@ -46,7 +44,7 @@ class TestCache extends ApolloCache<unknown> {
     return new Promise<void>(() => null);
   }
 
-  public restore(serializedState: unknown): ApolloCache<unknown> {
+  public restore(serializedState: unknown) {
     return this;
   }
 
diff --git a/src/cache/inmemory/__tests__/entityStore.ts b/src/cache/inmemory/__tests__/entityStore.ts
--- a/src/cache/inmemory/__tests__/entityStore.ts
+++ b/src/cache/inmemory/__tests__/entityStore.ts
@@ -1690,7 +1690,7 @@ describe("EntityStore", () => {
       }
     `;
 
-    function writeInitialData(cache: ApolloCache<any>) {
+    function writeInitialData(cache: ApolloCache) {
       cache.writeQuery({
         query,
         data: {
diff --git a/src/core/__tests__/ApolloClient/general.test.ts b/src/core/__tests__/ApolloClient/general.test.ts
--- a/src/core/__tests__/ApolloClient/general.test.ts
+++ b/src/core/__tests__/ApolloClient/general.test.ts
@@ -38,9 +38,9 @@ import {
 // This was originally imported from the ObservableQuery test, but the import
 // causes that test file to run when trying to run just this file so this is now
 // inlined.
-const mockFetchQuery = (queryManager: QueryManager<any>) => {
+const mockFetchQuery = (queryManager: QueryManager) => {
   const fetchObservableWithInfo = queryManager["fetchObservableWithInfo"];
-  const fetchQueryByPolicy: QueryManager<any>["fetchQueryByPolicy"] = (
+  const fetchQueryByPolicy: QueryManager["fetchQueryByPolicy"] = (
     queryManager as any
   ).fetchQueryByPolicy;
 
@@ -1748,10 +1748,12 @@ describe("ApolloClient", () => {
       },
     };
 
+    const cache = new InMemoryCache({
+      dataIdFromObject: getIdField,
+    });
+
     const client = new ApolloClient({
-      cache: new InMemoryCache({
-        dataIdFromObject: getIdField,
-      }),
+      cache,
       link: new MockLink([
         {
           request: { query: mutation },
@@ -1765,7 +1767,7 @@ describe("ApolloClient", () => {
     expect(result).toEqualFetchResult({ data });
 
     // Make sure we updated the store with the new data
-    expect(client.cache.extract()["5"]).toEqual({
+    expect(cache.extract()["5"]).toEqual({
       id: "5",
       isPrivate: true,
     });
@@ -1786,10 +1788,11 @@ describe("ApolloClient", () => {
         isPrivate: true,
       },
     };
+    const cache = new InMemoryCache({
+      dataIdFromObject: getIdField,
+    });
     const client = new ApolloClient({
-      cache: new InMemoryCache({
-        dataIdFromObject: getIdField,
-      }),
+      cache,
       link: new MockLink([
         {
           request: { query: mutation },
@@ -1803,7 +1806,7 @@ describe("ApolloClient", () => {
     expect(result).toEqualFetchResult({ data });
 
     // Make sure we updated the store with the new data
-    expect(client.cache.extract()["5"]).toEqual({
+    expect(cache.extract()["5"]).toEqual({
       id: "5",
       isPrivate: true,
     });
@@ -1826,10 +1829,11 @@ describe("ApolloClient", () => {
       },
     };
 
+    const cache = new InMemoryCache({
+      dataIdFromObject: getIdField,
+    });
     const client = new ApolloClient({
-      cache: new InMemoryCache({
-        dataIdFromObject: getIdField,
-      }),
+      cache,
       link: new MockLink([
         {
           request: { query: mutation },
@@ -1843,7 +1847,7 @@ describe("ApolloClient", () => {
     expect(result).toEqualFetchResult({ data });
 
     // Make sure we updated the store with the new data
-    expect(client.cache.extract()["5"]).toEqual({
+    expect(cache.extract()["5"]).toEqual({
       id: "5",
       isPrivate: true,
     });
@@ -2170,8 +2174,9 @@ describe("ApolloClient", () => {
         lastName: "Pandya",
       },
     };
+    const cache = new InMemoryCache();
     const client = new ApolloClient({
-      cache: new InMemoryCache(),
+      cache,
       link: new MockLink([
         {
           request: { query },
@@ -2196,7 +2201,7 @@ describe("ApolloClient", () => {
       client.query({ query, fetchPolicy: "network-only" })
     ).rejects.toThrow();
 
-    expect(client.cache.extract().ROOT_QUERY!.author).toEqual(data.author);
+    expect(cache.extract().ROOT_QUERY!.author).toEqual(data.author);
   });
 
   it("should be able to unsubscribe from a polling query subscription", async () => {
@@ -2260,8 +2265,9 @@ describe("ApolloClient", () => {
         lastName: "Smith",
       },
     };
+    const cache = new InMemoryCache();
     const client = new ApolloClient({
-      cache: new InMemoryCache(),
+      cache,
       link: new MockLink([
         {
           request: { query },
@@ -2286,7 +2292,7 @@ describe("ApolloClient", () => {
       networkStatus: NetworkStatus.ready,
       partial: false,
     });
-    expect(client.cache.extract().ROOT_QUERY!.author).toEqual(data.author);
+    expect(cache.extract().ROOT_QUERY!.author).toEqual(data.author);
 
     await expect(stream).toEmitApolloQueryResult({
       data,
@@ -2295,7 +2301,7 @@ describe("ApolloClient", () => {
       networkStatus: NetworkStatus.error,
       partial: false,
     });
-    expect(client.cache.extract().ROOT_QUERY!.author).toEqual(data.author);
+    expect(cache.extract().ROOT_QUERY!.author).toEqual(data.author);
   });
 
   it("should not fire next on an observer if there is no change in the result", async () => {
@@ -3034,7 +3040,7 @@ describe("ApolloClient", () => {
 
     const mocks = mockFetchQuery(queryManager);
     const queryId = "1";
-    const getQuery: QueryManager<any>["getQuery"] = (
+    const getQuery: QueryManager["getQuery"] = (
       queryManager as any
     ).getQuery.bind(queryManager);
 
diff --git a/src/core/__tests__/ObservableQuery.ts b/src/core/__tests__/ObservableQuery.ts
--- a/src/core/__tests__/ObservableQuery.ts
+++ b/src/core/__tests__/ObservableQuery.ts
@@ -42,15 +42,15 @@ import {
 import type { ObservableAndInfo } from "../QueryManager.js";
 import { QueryManager } from "../QueryManager.js";
 
-export const mockFetchQuery = (queryManager: QueryManager<any>) => {
+export const mockFetchQuery = (queryManager: QueryManager) => {
   const mocks = {
     fetchObservableWithInfo: jest.fn<
       ObservableAndInfo<unknown>,
-      Parameters<QueryManager<any>["fetchObservableWithInfo"]>
+      Parameters<QueryManager["fetchObservableWithInfo"]>
     >(queryManager["fetchObservableWithInfo"].bind(queryManager)),
     fetchQueryByPolicy: jest.fn<
       ObservableAndInfo<unknown>,
-      Parameters<QueryManager<any>["fetchQueryByPolicy"]>
+      Parameters<QueryManager["fetchQueryByPolicy"]>
     >(queryManager["fetchQueryByPolicy"].bind(queryManager)),
   };
 
diff --git a/src/react/context/__tests__/ApolloProvider.test.tsx b/src/react/context/__tests__/ApolloProvider.test.tsx
--- a/src/react/context/__tests__/ApolloProvider.test.tsx
+++ b/src/react/context/__tests__/ApolloProvider.test.tsx
@@ -31,7 +31,7 @@ describe("<ApolloProvider /> Component", () => {
 
   it("should support the 2.0", () => {
     render(
-      <ApolloProvider client={{} as ApolloClient<any>}>
+      <ApolloProvider client={{} as ApolloClient}>
         <div className="unique">Test</div>
       </ApolloProvider>
     );
@@ -114,8 +114,8 @@ describe("<ApolloProvider /> Component", () => {
   describe.each<
     [
       string,
-      Omit<ApolloProviderProps<any>, "children">,
-      Omit<ApolloProviderProps<any>, "children">,
+      Omit<ApolloProviderProps, "children">,
+      Omit<ApolloProviderProps, "children">,
     ]
   >([["client", { client }, { client: anotherClient }]])(
     "context value stability, %s prop",
diff --git a/src/react/hooks/__tests__/useFragment.test.tsx b/src/react/hooks/__tests__/useFragment.test.tsx
--- a/src/react/hooks/__tests__/useFragment.test.tsx
+++ b/src/react/hooks/__tests__/useFragment.test.tsx
@@ -2438,7 +2438,7 @@ describe.skip("Type Tests", () => {
       fragmentName?: string;
       optimistic?: boolean;
       variables?: TVars;
-      client?: ApolloClient<any>;
+      client?: ApolloClient;
     }>();
   });
 });
diff --git a/src/react/hooks/__tests__/useLoadableQuery.test.tsx b/src/react/hooks/__tests__/useLoadableQuery.test.tsx
--- a/src/react/hooks/__tests__/useLoadableQuery.test.tsx
+++ b/src/react/hooks/__tests__/useLoadableQuery.test.tsx
@@ -240,7 +240,7 @@ async function renderWithMocks(
 
 async function renderWithClient(
   ui: React.ReactElement,
-  options: { client: ApolloClient<any> },
+  options: { client: ApolloClient },
   { render: doRender }: { render: AsyncRenderFn | typeof renderAsync }
 ) {
   const { client } = options;
diff --git a/src/react/hooks/__tests__/useMutation.test.tsx b/src/react/hooks/__tests__/useMutation.test.tsx
--- a/src/react/hooks/__tests__/useMutation.test.tsx
+++ b/src/react/hooks/__tests__/useMutation.test.tsx
@@ -1707,7 +1707,7 @@ describe("useMutation Hook", () => {
             expect(data).toBeUndefined();
             void createTodo({ variables });
 
-            const dataInStore = client.cache.extract(true);
+            const dataInStore = cache.extract(true);
             expect(dataInStore["Todo:1"]).toEqual(
               optimisticResponse.createTodo
             );
diff --git a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx
--- a/src/react/hooks/__tests__/useSuspenseQuery.test.tsx
+++ b/src/react/hooks/__tests__/useSuspenseQuery.test.tsx
@@ -72,13 +72,13 @@ import {
 
 const IS_REACT_19 = React.version.startsWith("19");
 
-type RenderSuspenseHookOptions<Props, TSerializedCache = {}> = Omit<
+type RenderSuspenseHookOptions<Props> = Omit<
   RenderHookOptions<Props>,
   "wrapper"
 > & {
-  client?: ApolloClient<TSerializedCache>;
+  client?: ApolloClient;
   link?: ApolloLink;
-  cache?: ApolloCache<TSerializedCache>;
+  cache?: ApolloCache;
   mocks?: MockedResponse[];
   strictMode?: boolean;
 };
diff --git a/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx b/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx
--- a/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx
+++ b/src/react/query-preloader/__tests__/createQueryPreloader.test.tsx
@@ -63,7 +63,7 @@ async function renderDefaultTestApp<TData>({
   client,
   queryRef,
 }: {
-  client: ApolloClient<any>;
+  client: ApolloClient;
   queryRef: QueryRef<TData>;
 }) {
   const renderStream = createRenderStream({
diff --git a/src/testing/core/mocking/mockClient.ts b/src/testing/core/mocking/mockClient.ts
--- a/src/testing/core/mocking/mockClient.ts
+++ b/src/testing/core/mocking/mockClient.ts
@@ -1,6 +1,5 @@
 import type { DocumentNode } from "graphql";
 
-import type { NormalizedCacheObject } from "@apollo/client/cache";
 import { InMemoryCache } from "@apollo/client/cache";
 import { ApolloClient } from "@apollo/client/core";
 
@@ -10,7 +9,7 @@ export function createMockClient<TData>(
   data: TData,
   query: DocumentNode,
   variables = {}
-): ApolloClient<NormalizedCacheObject> {
+): ApolloClient {
   return new ApolloClient({
     link: mockSingleLink({
       request: { query, variables },
diff --git a/src/testing/internal/renderHelpers.tsx b/src/testing/internal/renderHelpers.tsx
--- a/src/testing/internal/renderHelpers.tsx
+++ b/src/testing/internal/renderHelpers.tsx
@@ -6,7 +6,7 @@ import type { MockedProviderProps } from "@apollo/client/testing/react";
 import { MockedProvider } from "@apollo/client/testing/react";
 
 export function createClientWrapper(
-  client: ApolloClient<any>,
+  client: ApolloClient,
   Wrapper: React.JSXElementConstructor<{
     children: React.ReactNode;
   }> = React.Fragment
@@ -23,7 +23,7 @@ export function createClientWrapper(
 }
 
 export function createMockWrapper(
-  renderOptions: MockedProviderProps<any>,
+  renderOptions: MockedProviderProps,
   Wrapper: React.JSXElementConstructor<{
     children: React.ReactNode;
   }> = React.Fragment
diff --git a/src/testing/react/MockedProvider.tsx b/src/testing/react/MockedProvider.tsx
--- a/src/testing/react/MockedProvider.tsx
+++ b/src/testing/react/MockedProvider.tsx
@@ -10,10 +10,10 @@ import { ApolloProvider } from "@apollo/client/react/context";
 import type { MockedResponse } from "@apollo/client/testing/core";
 import { MockLink } from "@apollo/client/testing/core";
 
-export interface MockedProviderProps<TSerializedCache = {}> {
+export interface MockedProviderProps {
   mocks?: ReadonlyArray<MockedResponse<any, any>>;
   defaultOptions?: DefaultOptions;
-  cache?: ApolloCache<TSerializedCache>;
+  cache?: ApolloCache;
   resolvers?: Resolvers;
   childProps?: object;
   children?: any;
@@ -27,7 +27,7 @@ export interface MockedProviderProps<TSerializedCache = {}> {
 }
 
 interface MockedProviderState {
-  client: ApolloClient<any>;
+  client: ApolloClient;
 }
 
 export class MockedProvider extends React.Component<