@types/prop-types

  • Version 15.7.13
  • Published
  • 6.96 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

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: readonly 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 {}

                                          property key

                                          key: string | null;

                                            property props

                                            props: any;

                                              property type

                                              type: ReactComponentLike;

                                                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]> };

                                                                              type WeakValidationMap

                                                                              type WeakValidationMap<T> = {
                                                                              [K in keyof T]?: null extends T[K]
                                                                              ? Validator<T[K] | null | undefined>
                                                                              : undefined extends T[K]
                                                                              ? Validator<T[K] | null | undefined>
                                                                              : Validator<T[K]>;
                                                                              };
                                                                              • Like ValidationMap but treats undefined, null and optional properties the same. This type is only added as a migration path in React 19 where this type was removed from React. Runtime and compile time types would mismatch since you could see undefined at runtime when your types don't expect this type.

                                                                              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 onejsDocs.io badgeto 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
                                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](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>