TypeScript Version: 3.2.2
Search Terms:
Code
typeComponent<P>=(props: P)=>any;constmyHof=<ComposedComponentPropsextendsany>(ComposedComponent: Component<ComposedComponentProps>,)=>{typeWrapperComponentProps=ComposedComponentProps&{myProp: string};declareconstWrapperComponent: Component<WrapperComponentProps>;declareconstprops: ComposedComponentProps;// Expected no error, got none - goodWrapperComponent({ ...props,myProp: '1000000'});// Expected error, got one - goodWrapperComponent({ ...props,myProp: 1000000});}However, when I try to do the same with React (.tsx):
importReactfrom'react';constmyHoc=<ComposedComponentPropsextendsany>(ComposedComponent: React.ComponentClass<ComposedComponentProps>,)=>{typeWrapperComponentProps=ComposedComponentProps&{myProp: string};declareconstWrapperComponent: React.ComponentClass<WrapperComponentProps>;declareconstprops: ComposedComponentProps;// Expected no error, got none - good<WrapperComponent{...props}myProp={'1000000'}/>;// Expected error, but got none - bad!<WrapperComponent{...props}myProp={1000000}/>;};
TypeScript Version: 3.2.2
Search Terms:
Code
However, when I try to do the same with React (
.tsx):