Add checkPropTypes definition to @types/prop-types

I used the jsdoc as guide in
https://github.com/facebook/prop-types/blob/master/checkPropTypes.js
This commit is contained in:
jethro larson 2018-05-07 19:43:25 -07:00
parent 27e6a748e9
commit ee0fd76b1a
2 changed files with 14 additions and 0 deletions

View File

@ -28,3 +28,15 @@ export function oneOfType(types: Array<Validator<any>>): Requireable<any>;
export function arrayOf(type: Validator<any>): Requireable<any>;
export function objectOf(type: Validator<any>): Requireable<any>;
export function shape(type: ValidationMap<any>): Requireable<any>;
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param typeSpecs Map of name to a ReactPropType
* @param values Runtime values that need to be type-checked
* @param location e.g. "prop", "context", "child context"
* @param componentName Name of the component for error messages.
* @param getStack Returns the component stack.
*/
export function checkPropTypes(typeSpecs: any, values: any, location: string, componentName: string, getStack?: () => any): void;

View File

@ -25,3 +25,5 @@ const propTypes: PropTypes.ValidationMap<Props> = {
node: PropTypes.node.isRequired,
element: PropTypes.element.isRequired
};
PropTypes.checkPropTypes({xs: PropTypes.array}, {xs: []}, 'location', 'componentName');