FakeBaseQuery references an inaccessible 'unique symbol' type.
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
@sebastienlabine Hi, any solution about this error? I encountered the error too
@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.'
)
}
}
Not clear if this is still an issue, so closing.