@types/prop-types
- Version 15.7.6
- Published
- 6.55 kB
- No dependencies
- MIT license
Install
npm i @types/prop-types
yarn add @types/prop-types
pnpm add @types/prop-types
Overview
TypeScript definitions for prop-types
Index
Variables
Functions
Interfaces
Type Aliases
Variables
variable any
const any: Requireable<any>;
variable array
const array: Requireable<any[]>;
variable bool
const bool: Requireable<boolean>;
variable element
const element: Requireable<ReactElementLike>;
variable elementType
const elementType: Requireable<ReactComponentLike>;
variable func
const func: Requireable<(...args: any[]) => any>;
variable node
const node: Requireable<ReactNodeLike>;
variable nominalTypeHack
const nominalTypeHack: Symbol;
variable number
const number: Requireable<number>;
variable object
const object: Requireable<object>;
variable string
const string: Requireable<string>;
variable symbol
const symbol: Requireable<symbol>;
Functions
function arrayOf
arrayOf: <T>(type: Validator<T>) => Requireable<T[]>;
function checkPropTypes
checkPropTypes: ( typeSpecs: any, values: any, location: string, componentName: string, getStack?: () => any) => void;
Assert that the values match with the type specs. Error messages are memorized and will only be shown once.
Parameter typeSpecs
Map of name to a ReactPropType
Parameter values
Runtime values that need to be type-checked
Parameter location
e.g. "prop", "context", "child context"
Parameter componentName
Name of the component for error messages
Parameter getStack
Returns the component stack
function exact
exact: <P extends ValidationMap<any>>( type: P) => Requireable<Required<InferProps<P>>>;
function instanceOf
instanceOf: <T>(expectedClass: new (...args: any[]) => T) => Requireable<T>;
function objectOf
objectOf: <T>(type: Validator<T>) => Requireable<{ [x: string]: T }>;
function oneOf
oneOf: <T>(types: ReadonlyArray<T>) => Requireable<T>;
function oneOfType
oneOfType: <T extends Validator<any>>( types: T[]) => Requireable<NonNullable<InferType<T>>>;
function resetWarningCache
resetWarningCache: () => void;
Only available if NODE_ENV=production
function shape
shape: <P extends ValidationMap<any>>(type: P) => Requireable<InferProps<P>>;
Interfaces
interface ReactElementLike
interface ReactElementLike {}
interface ReactNodeArray
interface ReactNodeArray extends Iterable<ReactNodeLike> {}
interface Requireable
interface Requireable<T> extends Validator<T | undefined | null> {}
property isRequired
isRequired: Validator<NonNullable<T>>;
interface Validator
interface Validator<T> {}
property [nominalTypeHack]
[nominalTypeHack]?: | { type: T; } | undefined;
call signature
( props: { [key: string]: any }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
Type Aliases
type InferProps
type InferProps<V> = InferPropsInner<Pick<V, RequiredKeys<V>>> & Partial<InferPropsInner<Pick<V, OptionalKeys<V>>>>;
type InferPropsInner
type InferPropsInner<V> = { [K in keyof V]-?: InferType<V[K]> };
type InferType
type InferType<V> = V extends Validator<infer T> ? T : any;
type IsOptional
type IsOptional<T> = undefined extends T ? true : false;
type OptionalKeys
type OptionalKeys<V> = Exclude<keyof V, RequiredKeys<V>>;
type ReactComponentLike
type ReactComponentLike = | string | ((props: any, context?: any) => any) | (new (props: any, context?: any) => any);
type ReactNodeLike
type ReactNodeLike = | ReactElementLike | ReactNodeArray | string | number | boolean | null | undefined;
type RequiredKeys
type RequiredKeys<V> = { [K in keyof V]-?: Exclude<V[K], undefined> extends Validator<infer T> ? IsOptional<T> extends true ? never : K : never;}[keyof V];
type ValidationMap
type ValidationMap<T> = { [K in keyof T]?: Validator<T[K]> };
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/prop-types
.
- Markdown[](https://www.jsdocs.io/package/@types/prop-types)
- HTML<a href="https://www.jsdocs.io/package/@types/prop-types"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2834 ms. - Missing or incorrect documentation? Open an issue for this package.