Closed
Description
The fix in #15687 did not get the original issue resolved, now that we have the apparent type, we can not spread T
into a Component<T>
.
here are a few samples:
import * as React from "react";
const decorator = function <T>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
return (props) => <Component {...props} ></Component> // should be ok
};
const decorator2 = function <T extends { x: number }>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
return (props) => <Component {...props} x={2} ></Component> // Should be ok, x is known
};
const decorator4 = function <T extends { x: number }>(Component: React.StatelessComponent<T>): React.StatelessComponent<T> {
return (props) => <Component {...props} y={"blah"} ></Component> // Should be an error, unknown y
};