Skip to content

[RTK v2.0] createApi (React) exceeds the maximum length the compiler will serialize #3591

Closed
@eric-crowell

Description

@eric-crowell

Version: 2.0.0-beta.0
Hello, I'm having an issue inferring types when using createApi from @reduxjs/toolkit/query/react.

I get this issue with a very minimal setup.

Code Sandbox link

import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";

/**
 * `myApiReact` defaults to the `any` type producing the TypeScript error....
 * The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056)
 */ 
export const myApiReact = createApi({
  reducerPath: "myApiReact",
  baseQuery: fetchBaseQuery({
    baseUrl: "/",
  }),
  endpoints: (builder) => ({
    getData: builder.query<{}, string>({
      query: (id) => `data/${id}`,
    }),
  }),
});

I can't find the cause of it yet. Seems like there's some type recursion happening somewhere in enhanceEndpoints when the react module is used? Maybe someone has a better clue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions