reduxjs / redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development
https://redux-toolkit.js.org
MIT License
10.76k stars 1.18k forks source link

`upsertQueryEntries`: `any` value assignment #4712

Closed JacobJaffe closed 2 weeks ago

JacobJaffe commented 2 weeks ago

Hello, I'm working on migrating to use upsertQueryEntries (and very excited about it!)

Any use of upsertQueryEntries seems to trip my typescript-eslint/no-unsafe-call / typescript-eslint/no-unsafe-assignlinting.

I haven't encountered this elsewhere using RTK -- I'm not sure what's going on here, since the action creator seems like it would be well typed.

Here's a minimal example of this:

const newApi = createApi({
  reducerPath: "foo",
  baseQuery: fetchBaseQuery({ baseUrl: "/api" }),
  endpoints: (builder) => ({
    getFoo: builder.query<string, string>({
      query: (foo) => `/${foo}`,
    }),
  }),
});

const uqe = newApi.util.upsertQueryEntries;

Image

markerikson commented 2 weeks ago

That seems pretty odd.

Can you share a project or CodeSandbox that shows this happening?

What does TS show as the actual type of newApi.util.upsertQueryEntries itself?

JacobJaffe commented 2 weeks ago

The TS type of upsertQueryEntries appears to be the same:

(property) upsertQueryEntries: UpsertEntries<{
    getFoo: QueryDefinition<string, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError, {}, FetchBaseQueryMeta>, never, string, "foo">;
}>

Image

I'll put together a minimal sharable project that reproduces this shortly

JacobJaffe commented 2 weeks ago

I've been unable to reproduce this in a fresh environment, and am no longer seeing this in my project after reinstalling dependencies. Closing this issue.