TypeScript Versions: 2.2.2, and the 2.3.0 mistakenly released last week
Code
import*asReactfrom'react';import{ComponentClass,StatelessComponent}from'react';exporttypeComponentType<P>=ComponentClass<P>|StatelessComponent<P>;exportfunctionwithProps<P1,P2>(Component: ComponentType<P1&P2>,props1: P1){return(props2: P2)=><Component{...props1}{...props2}/>;}Expected behavior:
Successful compilation.
Actual behavior:
TS2324: Property 'children' is missing in type '(IntrinsicAttributes & IntrinsicClassAttributes<Component<P1 & P2, ComponentState>> & Readonly<{ ...'.
Seems to me that this should be possible, since separate functions for each half of the union type pass the typechecker successfully:
functionwithProps2<P1,P2>(Component: StatelessComponent<P1&P2>,props1: P1){return(props2: P2)=><Component{...props1}{...props2}/>;}functionwithProps3<P1,P2>(Component: ComponentClass<P1&P2>,props1: P1){return(props2: P2)=><Component{...props1}{...props2}/>;}
TypeScript Versions: 2.2.2, and the 2.3.0 mistakenly released last week
Code
Expected behavior:
Successful compilation.
Actual behavior:
TS2324: Property 'children' is missing in type '(IntrinsicAttributes & IntrinsicClassAttributes<Component<P1 & P2, ComponentState>> & Readonly<{ ...'.Seems to me that this should be possible, since separate functions for each half of the union type pass the typechecker successfully: