Skip to content

Typescript error with providesTags #4547

Closed
@joaopedrocoelho

Description

@joaopedrocoelho

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 :

const api = customCreateApi({
    reducerPath: 'API',
    baseQuery: baseQueryWithReauth,
    endpoints: () => ({}),
});

api.enhanceEndpoints({
    addTagTypes: [
        'auth/passwordless',
        'auth/verify',
        'auth/renew',
    ],
});

export { api };

but now in the individual endpoints files I'm getting a typescript error with provideTags :

const AuthApi = api.injectEndpoints({
    endpoints: builder => ({
        PasswordlessGet: builder.query<
            PasswordlessSuccessResponse,
            PasswordlessRequestBody
        >({
            query: body => {
                console.log('running passwordless get');
                return {
                    url: 'auth/passwordless',
                    method: 'POST',
                    body: body,
                };
            },
            providesTags: ['auth/passwordless'],
        }),
   })
})

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 and typescript@5.4.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions