mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 19:09:18 +08:00
react: make defaultProps Partial<P>
Added a test, which ensures that defaultProps are Partial
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user