1+ declare module 'prop-types' {
2+ // Type definitions for prop-types 15.5
3+ // Project: https://github.com/reactjs/prop-types
4+ // Definitions by: DovydasNavickas <https://github.com/DovydasNavickas>
5+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
6+ // TypeScript Version: 2.2
7+
8+ export type Validator < T > = ( object : T , key : string , componentName : string , ...rest : any [ ] ) => Error | null ;
9+
10+ // psegalen: modified original declaration because of
11+ // "error TS2312: An interface may only extend a class or another interface."
12+ export interface Requireable < T > {
13+ isRequired : Validator < T > ;
14+ }
15+
16+ export type ValidationMap < T > = { [ K in keyof T ] ?: Validator < T > } ;
17+
18+ export const any : Requireable < any > & Validator < any > ;
19+ export const array : Requireable < any > & Validator < any > ;
20+ export const bool : Requireable < any > & Validator < any > ;
21+ export const func : Requireable < any > & Validator < any > ;
22+ export const number : Requireable < any > & Validator < any > ;
23+ export const object : Requireable < any > & Validator < any > ;
24+ export const string : Requireable < any > & Validator < any > ;
25+ export const node : Requireable < any > & Validator < any > ;
26+ export const element : Requireable < any > & Validator < any > ;
27+ export function instanceOf ( expectedClass : { } ) : Requireable < any > & Validator < any > ;
28+ export function oneOf ( types : any [ ] ) : Requireable < any > & Validator < any > ;
29+ export function oneOfType ( types : Array < Validator < any > > ) : Requireable < any > & Validator < any > ;
30+ export function arrayOf ( type : Validator < any > ) : Requireable < any > & Validator < any > ;
31+ export function objectOf ( type : Validator < any > ) : Requireable < any > & Validator < any > ;
32+ export function shape ( type : ValidationMap < any > ) : Requireable < any > & Validator < any > ;
33+ }
0 commit comments