TypeScript Version: 3.9.2
Search Terms: generic pipe pipeWith react memo HOC props any
Code
import*asReactfrom'react';declarefunctionpipeWith<A,B>(a: A,ab: (a: A)=>B): B;typeProps={foo: number};declareconstMyComponent: React.FunctionComponent<Props>;// ✅ correct props type// React.NamedExoticComponent<Props>constr1=React.memo(MyComponent);// ❌ `any` props type// React.MemoExoticComponent<React.ComponentType<any>>constr2=pipeWith(MyComponent,React.memo);// Workaround// ✅ correct props type// React.NamedExoticComponent<Props>constr3=pipeWith(MyComponent,(C)=>React.memo(C));Using latest version of @types/react (at the time of writing: 16.9.35).
Expected behavior:
See above.
Actual behavior:
See above.
Playground Link:
https://stackblitz.com/edit/react-ts-4ih6jn
Related Issues:
#25637, although that was closed as a duplicate of an issue which has since been closed (#10957), so I decided to post a new issue.
TypeScript Version: 3.9.2
Search Terms: generic pipe pipeWith react memo HOC props any
Code
Using latest version of
@types/react(at the time of writing: 16.9.35).Expected behavior:
See above.
Actual behavior:
See above.
Playground Link:
https://stackblitz.com/edit/react-ts-4ih6jn
Related Issues:
#25637, although that was closed as a duplicate of an issue which has since been closed (#10957), so I decided to post a new issue.