Skip to content

The inferred type of 'useLatestProductsQuery' cannot be named without a reference to '../../../node_modules/@reduxjs/toolkit/dist/query/react/buildHooks'. This is likely not portable. A type annotation is necessary. How to resolve this error? #4498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Abhishekiitb25 opened this issue Jul 7, 2024 · 5 comments

Comments

@Abhishekiitb25
Copy link

import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import { AllProductsResponse, CategoriesResponse } from "../../types/api-types";

export const productAPI = createApi({
reducerPath: "productApi",
baseQuery: fetchBaseQuery({
baseUrl: ${import.meta.env.VITE_SERVER}/api/v1/product/,
}),
endpoints: (builder) => ({
latestProducts: builder.query<AllProductsResponse, string>({
query: () => "latest",
}),
allProducts: builder.query<AllProductsResponse, string>({
query: (id) => admin-produc?id=${id},
}),
categories: builder.query<CategoriesResponse, string>({
query: () => categories,
}),
}),
});

export const {
useLatestProductsQuery,
useAllProductsQuery,
useCategoriesQuery,
} = productAPI;

@Abhishekiitb25 Abhishekiitb25 changed the title The inferred type of 'useLatestProductsQuery' cannot be named without a reference to '../../../node_modules/@reduxjs/toolkit/dist/query/react/buildHooks'. This is likely not portable. A type annotation is necessary The inferred type of 'useLatestProductsQuery' cannot be named without a reference to '../../../node_modules/@reduxjs/toolkit/dist/query/react/buildHooks'. This is likely not portable. A type annotation is necessary. How to resolve this error? Jul 7, 2024
@aryaemami59
Copy link
Member

aryaemami59 commented Jul 9, 2024

Can you run this command and try again to see if it fixes the issue:

npm install https://pkg.csb.dev/reduxjs/redux-toolkit/commit/06a30ee4/@reduxjs/toolkit

@Karangetang
Copy link

Karangetang commented Jul 9, 2024

I had the same issue. Added the commit as requested, and error was gone.

@reduxjs/toolkit 2.2.6
image

@reduxjs/toolkit 93cbe55
image

@devsrsihab
Copy link

Can you run this command and try again to see if it fixes the issue:

npm install https://pkg.csb.dev/reduxjs/redux-toolkit/commit/06a30ee4/@reduxjs/toolkit

Thanks i have run it and fixed the typescript Error, thanks man.

@glasody
Copy link

glasody commented Jul 23, 2024

for me adding "baseUrl": ".", to tsconfig fixed it

@markerikson
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants