diff --git a/react/index.d.ts b/react/index.d.ts index 6a2883c073..7ae52104b3 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -2282,7 +2282,7 @@ declare namespace React { // ---------------------------------------------------------------------- interface Validator { - (object: T, key: string, componentName: string): Error; + (object: T, key: string, componentName: string, ...rest: any[]): Error; } interface Requireable extends Validator { diff --git a/react/react-tests.ts b/react/react-tests.ts index 9c2a779660..9d7ee383dc 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -372,6 +372,17 @@ var PropTypesSpecification: React.ComponentSpec = { return new Error("Validation failed!"); } return null; + }, + // https://facebook.github.io/react/warnings/dont-call-proptypes.html#fixing-the-false-positive-in-third-party-proptypes + percentage: (object: any, key: string, componentName: string, ...rest: any[]): Error => { + const error = React.PropTypes.number(object, key, componentName, ...rest); + if (error) { + return error; + } + if (object[key] < 0 || object[key] > 100) { + return new Error(`prop ${key} must be between 0 and 100`); + } + return null; } }, render: (): React.ReactElement => {