reselect: 4.0.0
typescript: 3.2.2
The following code produces TS error.
// tsconfig.json
{
"compilerOptions": {
"strictFunctionTypes": true
}
}
// app.ts
import { createStructuredSelector } from 'reselect';
type GlobalState = {
foo: string;
bar: number;
};
const selectFoo = (state: GlobalState) => state.foo;
const selectBar = (state: GlobalState) => state.bar;
const injectState = createStructuredSelector({
foo: selectFoo, // error
bar: selectBar, // error
});
Error text
Type '(state: GlobalState) => string' is not assignable to type 'ParametricSelector<{}, {}, string>'.
Types of parameters 'state' and 'state' are incompatible.
Type '{}' is missing the following properties from type 'GlobalState': foo, bar [2322]
With strictFunctionTypes disabled, everything works fine. What is the correct way of using createStructuredSelector in TypeScript withstrictFunctionTypes option?
reselect: 4.0.0
typescript: 3.2.2
The following code produces TS error.
Error text
With
strictFunctionTypesdisabled, everything works fine. What is the correct way of usingcreateStructuredSelectorin TypeScript withstrictFunctionTypesoption?