-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Typescript error with providesTags #4547
Comments
You may need to add |
You need to export the result of edit: oops, wrong account |
@eskimojo-alt So how I'm going to add new tags and make sure every endpoints use the same api ? Like how can I get this to work : getPosts: builder.query<
CmsData,
{
slug: string;
}
>({
query: body => {
return {
url: `api/posts/$?filters[holdingSlug][$eq]=${body.slug}`,
method: 'GET',
};
},
transformResponse: (response: CmsPostsResponseBody) => {
return response.data[0];
},
providesTags: result => {
return result ? [...result.attributes.holdingSlug] : [];
},
}), this give me a TS error on providesTags : Type '(result: CmsPostData | undefined) => string[]' is not assignable to type 'ResultDescription<never, CmsPostData, { slug: string; }, FetchBaseQueryError, {} | undefined> | undefined'.
Type '(result: CmsPostData| undefined) => string[]' is not assignable to type 'GetResultDescriptionFn<never, CmsPostData, { slug: string; }, FetchBaseQueryError, {} | undefined>'.
Type 'string[]' is not assignable to type 'readonly FullTagDescription<never>[]'.
Type 'string' is not assignable to type 'FullTagDescription<never>'. |
the |
kind of related to #1510
I refactored my code because I want to add dynamic tags to the API,
so I did this :
api.ts :
but now in the individual endpoints files I'm getting a typescript error with provideTags :
I will get this error in
provideTags
:Type 'string' is not assignable to type 'FullTagDescription<never>'.
What can I do to fix this?
I'm using
react-redux@9.1.0
andtypescript@5.4.5
The text was updated successfully, but these errors were encountered: