You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is with the variable "cs", since it's type is, which can be clearly seen in VSCode by hovering over the mouse. It is inferred by TS using the createSelector function:
Since it's state parameter's type is never, it is never gonna be compatible with Selector<RootState, number>.
We get the following TS error:
Type '((state: never) => number) & OutputSelectorFields<(args_0: MyAppState) => number & { clearCache: () => void; }> & { clearCache: () => void; }' is not assignable to type '(state: RootState) => number'.
Types of parameters 'state' and 'state' are incompatible.
Type 'RootState' is not assignable to type 'never'.ts(2322)
Looks like the problem is with defaulting TExtraModels to Record<string, never>. createSelector function infers never type for state:
Describe the bug
A selector function within the model's "selectors" key should return a type similar to this
(Let's assume the selector extracts a Product array from the RootState)
We have this RootModel and RootState
We have this model:
The problem is with the variable "cs", since it's type is, which can be clearly seen in VSCode by hovering over the mouse. It is inferred by TS using the createSelector function:
Since it's state parameter's type is
never
, it is never gonna be compatible withSelector<RootState, number>
.We get the following TS error:
Looks like the problem is with defaulting TExtraModels to
Record<string, never>
. createSelector function infersnever
type for state:I'm using the latest 4.5.x TypeScript.
Interestingly productsOk selector has no problem with typing.
Also if I define the RootStatePure like this:
Then the following works and TS has no typing problem:
The text was updated successfully, but these errors were encountered: