Socket
Socket
Sign inDemoInstall

@types/prop-types

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/prop-types - npm Package Compare versions

Comparing version 15.7.12 to 15.7.13

195

prop-types/index.d.ts

@@ -1,109 +0,114 @@

export type ReactComponentLike =
| string
| ((props: any, context?: any) => any)
| (new(props: any, context?: any) => any);
// eslint-disable-next-line @definitelytyped/export-just-namespace
export = PropTypes;
export interface ReactElementLike {
type: ReactComponentLike;
props: any;
key: string | null;
}
declare namespace PropTypes {
type ReactComponentLike =
| string
| ((props: any, context?: any) => any)
| (new(props: any, context?: any) => any);
export interface ReactNodeArray extends Iterable<ReactNodeLike> {}
interface ReactElementLike {
type: ReactComponentLike;
props: any;
key: string | null;
}
export type ReactNodeLike =
| ReactElementLike
| ReactNodeArray
| string
| number
| boolean
| null
| undefined;
interface ReactNodeArray extends Iterable<ReactNodeLike> {}
export const nominalTypeHack: unique symbol;
type ReactNodeLike =
| ReactElementLike
| ReactNodeArray
| string
| number
| boolean
| null
| undefined;
export type IsOptional<T> = undefined extends T ? true : false;
const nominalTypeHack: unique symbol;
export type RequiredKeys<V> = {
[K in keyof V]-?: Exclude<V[K], undefined> extends Validator<infer T> ? IsOptional<T> extends true ? never : K
: never;
}[keyof V];
export type OptionalKeys<V> = Exclude<keyof V, RequiredKeys<V>>;
export type InferPropsInner<V> = { [K in keyof V]-?: InferType<V[K]> };
type IsOptional<T> = undefined extends T ? true : false;
export interface Validator<T> {
(
props: { [key: string]: any },
propName: string,
componentName: string,
location: string,
propFullName: string,
): Error | null;
[nominalTypeHack]?: {
type: T;
} | undefined;
}
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 OptionalKeys<V> = Exclude<keyof V, RequiredKeys<V>>;
type InferPropsInner<V> = { [K in keyof V]-?: InferType<V[K]> };
export interface Requireable<T> extends Validator<T | undefined | null> {
isRequired: Validator<NonNullable<T>>;
}
interface Validator<T> {
(
props: { [key: string]: any },
propName: string,
componentName: string,
location: string,
propFullName: string,
): Error | null;
[nominalTypeHack]?: {
type: T;
} | undefined;
}
export type ValidationMap<T> = { [K in keyof T]?: Validator<T[K]> };
interface Requireable<T> extends Validator<T | undefined | null> {
isRequired: Validator<NonNullable<T>>;
}
/**
* Like {@link 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.
*/
export 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]>;
};
type ValidationMap<T> = { [K in keyof T]?: Validator<T[K]> };
export type InferType<V> = V extends Validator<infer T> ? T : any;
export type InferProps<V> =
& InferPropsInner<Pick<V, RequiredKeys<V>>>
& Partial<InferPropsInner<Pick<V, OptionalKeys<V>>>>;
/**
* Like {@link 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.
*/
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]>;
};
export const any: Requireable<any>;
export const array: Requireable<any[]>;
export const bool: Requireable<boolean>;
export const func: Requireable<(...args: any[]) => any>;
export const number: Requireable<number>;
export const object: Requireable<object>;
export const string: Requireable<string>;
export const node: Requireable<ReactNodeLike>;
export const element: Requireable<ReactElementLike>;
export const symbol: Requireable<symbol>;
export const elementType: Requireable<ReactComponentLike>;
export function instanceOf<T>(expectedClass: new(...args: any[]) => T): Requireable<T>;
export function oneOf<T>(types: readonly T[]): Requireable<T>;
export function oneOfType<T extends Validator<any>>(types: T[]): Requireable<NonNullable<InferType<T>>>;
export function arrayOf<T>(type: Validator<T>): Requireable<T[]>;
export function objectOf<T>(type: Validator<T>): Requireable<{ [K in keyof any]: T }>;
export function shape<P extends ValidationMap<any>>(type: P): Requireable<InferProps<P>>;
export function exact<P extends ValidationMap<any>>(type: P): Requireable<Required<InferProps<P>>>;
type InferType<V> = V extends Validator<infer T> ? T : any;
type InferProps<V> =
& InferPropsInner<Pick<V, RequiredKeys<V>>>
& Partial<InferPropsInner<Pick<V, OptionalKeys<V>>>>;
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param typeSpecs Map of name to a ReactPropType
* @param values Runtime values that need to be type-checked
* @param location e.g. "prop", "context", "child context"
* @param componentName Name of the component for error messages
* @param getStack Returns the component stack
*/
export function checkPropTypes(
typeSpecs: any,
values: any,
location: string,
componentName: string,
getStack?: () => any,
): void;
const any: Requireable<any>;
const array: Requireable<any[]>;
const bool: Requireable<boolean>;
const func: Requireable<(...args: any[]) => any>;
const number: Requireable<number>;
const object: Requireable<object>;
const string: Requireable<string>;
const node: Requireable<ReactNodeLike>;
const element: Requireable<ReactElementLike>;
const symbol: Requireable<symbol>;
const elementType: Requireable<ReactComponentLike>;
function instanceOf<T>(expectedClass: new(...args: any[]) => T): Requireable<T>;
function oneOf<T>(types: readonly T[]): Requireable<T>;
function oneOfType<T extends Validator<any>>(types: T[]): Requireable<NonNullable<InferType<T>>>;
function arrayOf<T>(type: Validator<T>): Requireable<T[]>;
function objectOf<T>(type: Validator<T>): Requireable<{ [K in keyof any]: T }>;
function shape<P extends ValidationMap<any>>(type: P): Requireable<InferProps<P>>;
function exact<P extends ValidationMap<any>>(type: P): Requireable<Required<InferProps<P>>>;
/**
* Only available if NODE_ENV=production
*/
export function resetWarningCache(): void;
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param typeSpecs Map of name to a ReactPropType
* @param values Runtime values that need to be type-checked
* @param location e.g. "prop", "context", "child context"
* @param componentName Name of the component for error messages
* @param getStack Returns the component stack
*/
function checkPropTypes(
typeSpecs: any,
values: any,
location: string,
componentName: string,
getStack?: () => any,
): void;
/**
* Only available if NODE_ENV=production
*/
function resetWarningCache(): void;
}
{
"name": "@types/prop-types",
"version": "15.7.12",
"version": "15.7.13",
"description": "TypeScript definitions for prop-types",

@@ -33,4 +33,4 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/prop-types",

"dependencies": {},
"typesPublisherContentHash": "9f43a310cba2ddc63b5ca98d9cce503eaead853f72f038eb5c29c623dc2c01b6",
"typeScriptVersion": "4.7"
"typesPublisherContentHash": "463997a2d1b4bb7e18554d9d12146cc74169e8bda6a4b9008306c38797ae14d3",
"typeScriptVersion": "4.8"
}

@@ -5,3 +5,3 @@ # Installation

# Summary
This package contains type definitions for prop-types (https://github.com/reactjs/prop-types).
This package contains type definitions for prop-types (https://github.com/facebook/prop-types).

@@ -12,3 +12,3 @@ # Details

### Additional Details
* Last updated: Fri, 22 Mar 2024 18:07:25 GMT
* Last updated: Mon, 16 Sep 2024 19:07:13 GMT
* Dependencies: none

@@ -15,0 +15,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc