UNPKG

1.25 kBTypeScriptView Raw
1// Type definitions for prop-types 15.5
2// Project: https://github.com/reactjs/prop-types
3// Definitions by: DovydasNavickas <https://github.com/DovydasNavickas>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.2
6
7export type Validator<T> = (object: T, key: string, componentName: string, ...rest: any[]) => Error | null;
8
9export interface Requireable<T> extends Validator<T> {
10 isRequired: Validator<T>;
11}
12
13export type ValidationMap<T> = {[K in keyof T]?: Validator<T> };
14
15export const any: Requireable<any>;
16export const array: Requireable<any>;
17export const bool: Requireable<any>;
18export const func: Requireable<any>;
19export const number: Requireable<any>;
20export const object: Requireable<any>;
21export const string: Requireable<any>;
22export const node: Requireable<any>;
23export const element: Requireable<any>;
24export function instanceOf(expectedClass: {}): Requireable<any>;
25export function oneOf(types: any[]): Requireable<any>;
26export function oneOfType(types: Array<Validator<any>>): Requireable<any>;
27export function arrayOf(type: Validator<any>): Requireable<any>;
28export function objectOf(type: Validator<any>): Requireable<any>;
29export function shape(type: ValidationMap<any>): Requireable<any>;