Description
openedon Jul 2, 2024
I'm trying to upgrade to Redux Toolkit v2 but running into a problem that I'm pretty sure is caused by the UpdateDefinitions
type not being exported from @reduxjs/toolkit/query
.
I have a monorepo with a separate package for my API endpoint, which is further split up into smaller chunks. @reduxjs/toolkit
is a peer dependency in that package.
I have a base API defined like this:
export const baseApi = createApi({
reducerPath: "api",
endpoints: () => ({}),
});
And the additional API chunks are handled similar to this:
export const authApi = baseApi
.enhanceEndpoints({
addTagTypes: ["Permissions"],
})
.injectEndpoints({
endpoints: (build) => ({
permissions: build.query<PermissionsResponse, void>({
query: () => "user/permissions",
providesTags: () => [{ type: "Permissions", id: "CURRENT" }],
}),
}),
});
This was working fine with v1, but after trying to upgrade to v2 I'm getting the error (at the authApi
definition):
The inferred type of 'authApi' cannot be named without a reference to '@reduxjs/toolkit/dist/query/endpointDefinitions'. This is likely not portable. A type annotation is necessary.ts(2742)
If I remove the enhanceEndpoints
call (and leave just the injectEndpoints
call) the issues goes away, but then I can no longer use the "Permissions" tag in provideTags
. I'm fairly certain I've narrowed down the problem to the fact that the UpdateDefinitions
type used by enhanceEndpoints
is not exported by @reduxjs/toolkit/query
. All the other referenced types seem to be exported except for this one. Is there a specific reason for omitting it? Or was it an oversight? Would it be worth me putting up a PR to export it?