react: make defaultProps Partial<P>

Added a test, which ensures that defaultProps are Partial
This commit is contained in:
Artur Eshenbrener
2017-02-10 11:02:43 +03:00
parent d0128ad516
commit e875fc829a

View File

@@ -689,3 +689,18 @@ type InputChangeEvent = React.ChangeEvent<HTMLInputElement>;
type InputFormEvent = React.FormEvent<HTMLInputElement>;
const changeEvent:InputChangeEvent = undefined as any;
const formEvent:InputFormEvent = changeEvent;
// defaultProps should be optional of props
{
interface ComponentProps {
prop1: string;
prop2: string;
prop3?: string;
}
class ComponentWithDefaultProps extends React.Component<ComponentProps, void> {
static defaultProps = {
prop3: "default value",
};
}
const VariableWithAClass: React.ComponentClass<ComponentProps> = ComponentWithDefaultProps;
}