Definitelytyped: Problem with recompose `branch(condition, renderComponent(Component))`-pattern in TS 2.4

Created on 28 Jun 2017  路  4Comments  路  Source: DefinitelyTyped/DefinitelyTyped

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

Most helpful comment

Seems because of ComponentClass in @types/react #17567.

All 4 comments

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)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

csharpner picture csharpner  路  3Comments

alisabzevari picture alisabzevari  路  3Comments

variousauthors picture variousauthors  路  3Comments

Loghorn picture Loghorn  路  3Comments

lilling picture lilling  路  3Comments