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
[RTKQ] Type conflicts with TypedUseSelectorHook when using reselect 4.1.3 #1750
Comments
Can you show more details? What are the calculated state types here? |
I have been observing the same (I think) issue since a recent dependency upgrade. Wasn't able to track it down yet, but this is one of the full type errors:
|
Yes, but the original error is too long to display and read. After researching for a while, I found a smaller code that can cause errors: // from rtkq:
type QueryCacheKey = string & {
_type: 'queryCacheKey'
}
// from reselect
type Computed = /** from reselect */ ComputeDeep<QueryCacheKey>
type Extends = Computed extends QueryCacheKey ? true : false // => false And this is the result of Computed: type Computed = {
[x: number]: string;
toString: (() => string) & (() => string);
charAt: (pos: number) => string;
charCodeAt: (index: number) => number;
concat: (...strings: string[]) => string;
indexOf: (searchString: string, position?: number | undefined) => number;
... 44 more ...;
_type: 'queryCacheKey';
} |
|
type RootState = ReturnType<typeof store.getState>;
// => the result of it:
{
test: { ... },
// ...
api: {
queries: { ... },
mutations: { ... },
provided: { ... },
subscriptions: { ... }
}
} and // provided: InvalidationState<E>;
type InvalidationState<TagTypes extends string> = {
[_ in TagTypes]: {
[id: string]: Array<QueryCacheKey>;
};
}; Then, in /** Recursively expand all fields in an object for easier reading */
export type ExpandItems<T extends readonly unknown[]> = {
[index in keyof T]: T[index] extends T[number] ? ComputeDeep<T[index]> : never
} And in ComputeDeep:
It may not handle this form of These comprehensive reasons lead to the problem. It may not be a good description, I hope I made it clear(+﹏+)~ |
Hmm, |
Yeah, and that might be related to another Reselect 4.1.3 TS error someone reported today. I'll try adding these as additional typetest cases this evening and work to fix them. |
Related: reduxjs/reselect#550 |
Well, the "good" news is that I can reproduce this, and Investigating further... |
Yeah, confirmed that removing the I'm going to remove that line. It was an interesting idea but I don't think it's sufficiently useful. @Grapedge appreciate the detailed analysis and breakdown! |
Should be fixed in https://github.com/reduxjs/reselect/releases/tag/v4.1.4 . (Also: whoa! how did merging that PR close this issue, especially across repos? I guess I did say "fixes" + a link to this issue, sooooo.) |
Problems
code sandbox
When using RTKQ, there are some type conflicts here:
Versions
The text was updated successfully, but these errors were encountered: