Use case:
I have a custom hook useFoo
which needs to return values based on bar
property in store but typescript throws error.
Code:
export const useFoo = observer(() => {
// typescript throws error --^^^^^^^--
const { bar } = store;
return bar ? 'x' : 'y';
});
Typescript Errors:
Argument of type '() => "x" | "y"' is not assignable to parameter of type 'IReactComponent<any>'.
Type '() => "x" | "y"' is not assignable to type 'FunctionComponent<any>'.
Type '"x" | "y"' is not assignable to type 'ReactElement<any, any> | null'.
Type '"x"' is not assignable to type 'ReactElement<any, any> | null'.ts(2345)