mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #15736 from QuatroCode/master
prop-types package definitions
This commit is contained in:
Vendored
+29
@@ -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>;
|
||||
@@ -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
|
||||
};
|
||||
@@ -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" ]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Reference in New Issue
Block a user