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

FakeBaseQuery references an inaccessible 'unique symbol' type. #2314

Closed
sebastienlabine opened this issue May 10, 2022 · 4 comments
Closed

Comments

@sebastienlabine
Copy link

Hi,

I am building a library that exports redux-toolkit generated hooks in order to reuse theses hooks in multiple applications.

I encountered a problem while using fakeBaseQuery as baseQuery making all my hooks unsuable with typescripts:

(!) Plugin typescript: @rollup/plugin-typescript TS2527: The inferred type of 'bankAccountsAPI' references an inaccessible 'unique symbol' type. A type annotation is necessary.
src/apis/smartbills-api/banks/BankAccountsAPI.tsx: (6:14)

6 export const bankAccountsAPI = smartbillsAPI
               ~~~~~~~~~~~~~~~

As we can see in the fakeBaseQuery type definition, we are using a pure Symbol for the never type.

const _NEVER = /* @__PURE__ */ Symbol()
export type NEVER = typeof _NEVER

is there a reason to do so? I bypassed the error by creating my "own" fakeBaseQuery using the never type.

import { BaseQueryFn } from "@reduxjs/toolkit/dist/query/react"

export function fakeBaseQuery<ErrorType>(): BaseQueryFn<
    void,
    never,
    ErrorType,
    {}
> {
    return function () {
        throw new Error(
            'When using `fakeBaseQuery`, all queries & mutations must use the `queryFn` definition syntax.'
        )
    }
}

Thanks

@ytftianwen
Copy link

@sebastienlabine
Hi, any solution about this error? I encountered the error too

@sebastienlabine
Copy link
Author

@ytftianwen yes, I actually just created my own fake base query and used it as my baseQuery

import { BaseQueryFn } from "@reduxjs/toolkit/dist/query/react"

export function fakeBaseQuery<ErrorType>(): BaseQueryFn<
    void,
    never,
    ErrorType,
    {}
> {
    return function () {
        throw new Error(
            'When using `fakeBaseQuery`, all queries & mutations must use the `queryFn` definition syntax.'
        )
    }
}

@markerikson
Copy link
Collaborator

Not clear if this is still an issue, so closing.

@markerikson markerikson closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
@markerikson
Copy link
Collaborator

Fixed in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.2.7 !

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

3 participants