Skip to content
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

Consider exporting "TagDescription" from '@reduxjs/toolkit/dist/query' #2876

Closed
heath-pack opened this issue Nov 7, 2022 · 1 comment · Fixed by #2964
Closed

Consider exporting "TagDescription" from '@reduxjs/toolkit/dist/query' #2876

heath-pack opened this issue Nov 7, 2022 · 1 comment · Fixed by #2964
Milestone

Comments

@heath-pack
Copy link

heath-pack commented Nov 7, 2022

Right now TagDescription is defined at '@reduxjs/toolkit/dist/query/endpointDefinitions'. It would be nice if it could be added to the index and exported from @reduxjs/toolkit/dist/query' i.e. `import { type TagDescription } from '@reduxjs/toolkit/dist/query'

The TagDescription type would be nice to help just dry up code and share among multiple endpoints

The below example is a simplified version of what I am talking about, where TagTypes is an already defined Enum of tags.

function providesTagsForUserId(tagTypes: TagType[]) {
    return (_result: AnyObject | undefined, error: FetchBaseQueryError | undefined, userId: string) => {
        const tags: TagDescription<TagType>[] = [TagType.FrontRoyalStore];

        if (error) return tags;

        return tagTypes.reduce((prev, type) => [...prev, { type, id: userId }], tags);
    };
}

It would be nice if the above was possible and I could just set the tags variable to to be the correct type and not need to use
as const and tags as ({ type: TagType; id: string } | TagType)[],all over the place to get this to work out.

@markerikson
Copy link
Collaborator

Out in https://github.com/reduxjs/redux-toolkit/releases/tag/v1.9.1

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

Successfully merging a pull request may close this issue.

2 participants