Compose function can not deduce generic types of arguments if compose function is defined right to left #31738
Labels
Design Limitation
Constraints of the existing architecture prevent this from being fixed
TypeScript Version: 3.6.0-dev.20190603
Search Terms:
Compose doesn't infer generic types of arguments.
Code
Expected behavior:
I expect
doubleArray
to be inferred asnumber[][]
.Actual behavior:
It is inferred as
unknown
.I'm also not sure how to help typescript, to infer this correctly, for example, this doesn't work:
Playground Link:
Playground
Related Issues:
#10247
Interestingly, if we define compose from left to right, instead of the standard mathematical composition, it actually works:
Playground
I choose a very generic example, but the code that I actually try to type are HOC with react.
For example:
This code doesn't get inferred correctly, and also here, with the left to right compose function it does get inferred.
The text was updated successfully, but these errors were encountered: