Nozbe / withObservables

HOC (Higher-Order Component) for connecting RxJS Observables to React Components
https://github.com/Nozbe/WatermelonDB
MIT License
68 stars 26 forks source link

Typescript: withObservables does not properly check types #123

Open larkox opened 2 years ago

larkox commented 2 years ago

Let a component like:

const myComponent = ({myList: string[]}) => {
    ...
}

If we pass a more general within withObservables, instead of typescript complaining, it appears as valid:

const wo = withObservables() => {
    const list: Observable<(string|number)[]> = ...
    return {myList: list}
}

Expected result: Some error saying that types are not compatible, since the return type of withObservables ((string|number)[]) is not assignable to the props (string[]).

Some other examples: