How to fix TypeScript error: Argument of type... is not assignable to parameter of type TagDescription in React

ReactINTERMEDIATEMEDIUMUpdated Dec 11, 2025ยท 116 views

This TypeScript compilation error occurs when upgrading RTK Query to version 2.4.0 or later, where internal type definitions for tag descriptions cause compatibility issues even when not using tags in your API definitions.

Quick fix

Fixes TS2345

import { createApi } from '@reduxjs/toolkit/query/react';

export const api = createApi({
  reducerPath: 'api',
  baseQuery: fetchBaseQuery({ baseUrl: '/api' }),
  tagTypes: [] as const,  // Explicit empty array with const assertion
  endpoints: () => ({})
});
  1. Update your RTK Query API slice configuration
  2. Check for undefined tag descriptions in endpoints
  3. Temporarily downgrade RTK Query if needed
  4. Update TypeScript configuration if necessary
react โ€” error
import { createApi } from '@reduxjs/toolkit/query/react';
export const api = createApi({
reducerPath: 'api',
baseQuery: fetchBaseQuery({ baseUrl: '/api' }),
tagTypes: [] as const, // Explicit empty array with const assertion
endpoints: () => ({})
});
TypeScript error: Argument of type... is not assignable to parameter of type TagDescription

What this error means

The error indicates a type mismatch in RTK Query's internal tag handling system. When you upgrade to RTK Query 2.4.0+, the TypeScript definitions for tag descriptions become stricter, and the internal code that processes tags may receive undefined or null values where it expects defined TagDescription objects. This happens even if you're not explicitly using tags in your API slice definition.

Typical symptoms

  • TypeScript compilation fails with error TS2345 in @reduxjs/toolkit/src/query/endpointDefinitions.ts
  • Error message mentions "Argument of type ... is not assignable to parameter of type TagDescription"
  • The error occurs in RTK Query's internal code, specifically in the expandTagDescription function
  • Compilation works fine with RTK Query 2.3.0 but breaks with 2.4.0+
  • Error persists even when not using any tags or with empty tagTypes array

Common causes

  1. RTK Query 2.4.0 introduced stricter TypeScript type definitions for tag handling
  2. Internal type guards may not properly handle undefined or null values in tag description arrays
  3. The expandTagDescription function expects TagDescription objects but may receive undefined values
  4. TypeScript's strict null checking reveals previously hidden type issues
  5. Even empty tag definitions can trigger the internal type checking code path

How to fix "TypeScript error: Argument of type... is not assignable to parameter of type TagDescription"

1Update your RTK Query API slice configuration

Ensure your createApi call explicitly defines tagTypes as an empty array with const assertion. This helps TypeScript infer the correct types:

typescript
import { createApi } from '@reduxjs/toolkit/query/react';

export const api = createApi({
  reducerPath: 'api',
  baseQuery: fetchBaseQuery({ baseUrl: '/api' }),
  tagTypes: [] as const,  // Explicit empty array with const assertion
  endpoints: () => ({})
});
2Check for undefined tag descriptions in endpoints

If you have endpoints with providesTags or invalidatesTags, ensure they return proper tag descriptions and not undefined:

typescript
endpoints: (builder) => ({
  getItems: builder.query({
    query: () => '/items',
    providesTags: (result) =>
      result
        ? [...result.map(({ id }) => ({ type: 'Item' as const, id }))]
        : [{ type: 'Item' as const, id: 'LIST' }]
  })
})

Make sure the providesTags function always returns an array of tag descriptions, never undefined.

3Temporarily downgrade RTK Query if needed

If you need immediate compilation while investigating, you can temporarily revert to RTK Query 2.3.0:

bash
npm install @reduxjs/toolkit@1.9.7

Note: RTK Query 2.3.0 is bundled with @reduxjs/toolkit 1.9.7. This is a temporary workaround while you update your code to be compatible with 2.4.0+.

4Update TypeScript configuration if necessary

Ensure your TypeScript configuration has appropriate strictness settings. The error might be more visible with strictNullChecks enabled:

json
{
  "compilerOptions": {
    "strict": true,
    "strictNullChecks": true
  }
}

These settings help catch potential runtime errors at compile time.

5Check for updates or patches from the RTK team

Visit the RTK Query GitHub repository to check for reported issues and potential fixes:

- GitHub Issue: https://github.com/reduxjs/redux-toolkit/issues/4807
- Look for any patches or workarounds suggested by maintainers
- Consider updating to the latest version which may have fixes

The issue was reported and may be addressed in subsequent releases.

Advanced notes

This error highlights the importance of proper TypeScript configuration when using libraries with complex type systems. RTK Query uses advanced TypeScript features for type safety, and version upgrades may expose previously hidden type inconsistencies. When working with tagged caching systems, ensure all code paths return consistent tag descriptions. The const assertion (as const) is particularly important for TypeScript to infer literal types correctly in RTK Query tag definitions.

Frequently asked questions

What does "TS2345" mean?
The error indicates a type mismatch in RTK Query's internal tag handling system. 0+, the TypeScript definitions for tag descriptions become stricter, and the internal code that processes tags may receive undefined or null values where it expects defined TagDescription objects. This happens even if you're not explicitly using tags in your API slice definition.
How do I fix "TS2345"?
This TypeScript compilation error occurs when upgrading RTK Query to version 2.4.0 or later, where internal type definitions for tag descriptions cause compatibility issues even when not using tags in your API definitions.
What causes "TS2345"?
RTK Query 2.4.0 introduced stricter TypeScript type definitions for tag handling Internal type guards may not properly handle undefined or null values in tag description arrays The expandTagDescription function expects TagDescription objects but may receive undefined values
Is the "TS2345" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading