After upgrading to TypeScript 2.4.1, recompose's branch(condition, renderComponent(Component))-pattern - used in their docs - causes this error:
TS2345: Argument of type 'ComponentEnhancer<{}, {}>' is not assignable to parameter of type 'InferableComponentEnhancer'.
Type 'ComponentClass<{}>' is not assignable to type 'TComp'.
This particular error was fixed by changing the return type of renderComponent from ComponentEnhancer<any, any> to InferableComponentEnhancer for me, but I couldn't quite figure out the test suite nor the rest of the declaration file, so I didn't want to make a PR.
CC: Authors of the recompose declaration files: @iskandersierra, @mrapogee
Seems because of ComponentClass in @types/react #17567.
@ahstro did you manage to solve the problem according to @morlay comment? I am still having the problems getting it running.
@zunder I hacked it for now, using branch(something, renderComponent(Loading) as InferableComponentEnhancer)
I got the same problem but with hoistStatics.
const enhance = compose(...some)
export default hoistStatics(enhance)
Most helpful comment
Seems because of
ComponentClassin@types/react#17567.