mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-24 05:06:02 +08:00
Merge pull request #14424 from Strate/patch-2
react: make defaultProps Partial<P>
This commit is contained in:
4
react/index.d.ts
vendored
4
react/index.d.ts
vendored
@@ -207,7 +207,7 @@ declare namespace React {
|
||||
(props: P & { children?: ReactNode }, context?: any): ReactElement<any>;
|
||||
propTypes?: ValidationMap<P>;
|
||||
contextTypes?: ValidationMap<any>;
|
||||
defaultProps?: P;
|
||||
defaultProps?: Partial<P>;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ declare namespace React {
|
||||
propTypes?: ValidationMap<P>;
|
||||
contextTypes?: ValidationMap<any>;
|
||||
childContextTypes?: ValidationMap<any>;
|
||||
defaultProps?: P;
|
||||
defaultProps?: Partial<P>;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -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