You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/wrappedComponent.tsx:10:21 - error TS2322: Type '{ foo: number; }' is not assignable to type 'IntrinsicAttributes & P & { children?: ReactNode; }'.
Property 'foo' does not exist on type 'IntrinsicAttributes & P & { children?: ReactNode; }'.
10 return <WrappedComponent foo={0} />;
We corrected & tightened up our checking of generics in jsx - we had a nasty habit of erasing them before.
You're declaring that your WrappedComponent takes a P extends ComponentProps, but are only providing a ComponentProps to the WrappedComponent when its type states that you must provide a P. Usually you'd do this by spreading the input props to SomeHOC into your WrappedComponent tag.
Got it. The actual (non-example) code was using some cached props in the state, of type ComponentProps. By making the state itself similarly generic, it works.
TypeScript Version: 3.2.0-rc, 9319ea4
Search Terms:
higher order component, React, type parameter
Code
Expected behavior:
No error (as in 3.1.6)
Actual behavior:
Playground Link:
Related Issues:
Possibly #28636, #28647, #28719
The text was updated successfully, but these errors were encountered: