I need to type both stateless component and classic component in single component property:
TypeScript Version:
1.8.10/1.9.0-dev.20160518-1.0
Code
// A self-contained demonstration of the problem follows...
// Ideally:
interface ComponentProps {
ButtonComponent: React.StatelessComponent<any> | React.ComponentClass<any>;
...
}
class MyComponent extends React.Component<ComponentProps, {}> {
render() {
const { ButtonComponent } = this.props;
const someProps = {};
const button = <ButtonComponent {...someProps}/>
return (<div>{button}</div>);
}
}
// Ideal usage
<MyComponent ButtonComponent={() => <button>test</button>}/>
class MyButtonComponent extends React.Component<{},{}> {
...
}
<MyComponent ButtonComponent={MyButtonComponent} />
Expected behavior:
Compiles successfully
Actual behavior:
Throws error: "JSX Element type ButtonComponent doesn't have any construct or call signatures"
It works If i change definition of ButtonComponent to just solo React.StatelessComponent or
React.ComponentClass
I need to type both stateless component and classic component in single component property:
TypeScript Version:
1.8.10/1.9.0-dev.20160518-1.0
Code
Expected behavior:
Compiles successfully
Actual behavior:
Throws error: "JSX Element type ButtonComponent doesn't have any construct or call signatures"
It works If i change definition of ButtonComponent to just solo React.StatelessComponent or
React.ComponentClass