Merge pull request #15736 from QuatroCode/master

prop-types package definitions
This commit is contained in:
Ryan Cavanaugh
2017-04-17 10:11:26 -07:00
committed by GitHub
4 changed files with 77 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
// Type definitions for prop-types v15.5.4
// Project: https://github.com/reactjs/prop-types
// Definitions by: DovydasNavickas <https://github.com/DovydasNavickas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export type Validator<T> = (object: T, key: string, componentName: string, ...rest: any[]) => Error | null;
export interface Requireable<T> extends Validator<T> {
isRequired: Validator<T>;
}
export type ValidationMap<T> = {[K in keyof T]?: Validator<T> };
export const any: Requireable<any>;
export const array: Requireable<any>;
export const bool: Requireable<any>;
export const func: Requireable<any>;
export const number: Requireable<any>;
export const object: Requireable<any>;
export const string: Requireable<any>;
export const node: Requireable<any>;
export const element: Requireable<any>;
export function instanceOf(expectedClass: {}): Requireable<any>;
export function oneOf(types: any[]): Requireable<any>;
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>;
+25
View File
@@ -0,0 +1,25 @@
import * as PropTypes from "prop-types";
interface Props {
any: any;
array: string[];
bool: boolean;
func: any;
string: string;
number: number;
object: {};
node: any;
element: any;
}
let propTypes: PropTypes.ValidationMap<Props> = {
any: PropTypes.any.isRequired,
array: PropTypes.array.isRequired,
bool: PropTypes.bool.isRequired,
func: PropTypes.func.isRequired,
number: PropTypes.number.isRequired,
object: PropTypes.object.isRequired,
string: PropTypes.string.isRequired,
node: PropTypes.node.isRequired,
element: PropTypes.element.isRequired
};
+20
View File
@@ -0,0 +1,20 @@
{
"files": [
"index.d.ts",
"prop-types-tests.ts"
],
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"lib" : [ "es6" ]
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "../tslint.json"
}