mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[prop-types] add elementType and resetWarningCache
This commit is contained in:
parent
0e29f171fa
commit
cb1912dae8
9
types/prop-types/index.d.ts
vendored
9
types/prop-types/index.d.ts
vendored
@ -1,7 +1,8 @@
|
||||
// Type definitions for prop-types 15.5
|
||||
// Type definitions for prop-types 15.7
|
||||
// Project: https://github.com/reactjs/prop-types, https://facebook.github.io/react
|
||||
// Definitions by: DovydasNavickas <https://github.com/DovydasNavickas>
|
||||
// Ferdy Budhidharma <https://github.com/ferdaber>
|
||||
// Sebastian Silbermann <https://github.com/eps1lon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@ -62,6 +63,7 @@ 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: T[]): Requireable<T>;
|
||||
export function oneOfType<T extends Validator<any>>(types: T[]): Requireable<NonNullable<InferType<T>>>;
|
||||
@ -81,3 +83,8 @@ export function exact<P extends ValidationMap<any>>(type: P): Requireable<Requir
|
||||
* @param getStack Returns the component stack.
|
||||
*/
|
||||
export function checkPropTypes(typeSpecs: any, values: any, location: string, componentName: string, getStack?: () => any): void;
|
||||
|
||||
/**
|
||||
* Only available if NODE_ENV=production
|
||||
*/
|
||||
export function resetWarningCache(): void;
|
||||
|
||||
@ -34,6 +34,7 @@ interface Props {
|
||||
};
|
||||
optionalNumber?: number | null;
|
||||
customProp?: typeof uniqueType;
|
||||
component: PropTypes.ReactComponentLike;
|
||||
}
|
||||
|
||||
const innerProps = {
|
||||
@ -74,7 +75,8 @@ const propTypes: PropTypesMap = {
|
||||
objectOf: PropTypes.objectOf(PropTypes.number.isRequired).isRequired,
|
||||
shape: PropTypes.shape(innerProps).isRequired,
|
||||
optionalNumber: PropTypes.number,
|
||||
customProp: (() => null) as PropTypes.Validator<typeof uniqueType | undefined>
|
||||
customProp: (() => null) as PropTypes.Validator<typeof uniqueType | undefined>,
|
||||
component: PropTypes.elementType.isRequired
|
||||
};
|
||||
|
||||
// JS checking
|
||||
@ -100,7 +102,8 @@ const propTypesWithoutAnnotation = {
|
||||
objectOf: PropTypes.objectOf(PropTypes.number.isRequired).isRequired,
|
||||
shape: PropTypes.shape(innerProps).isRequired,
|
||||
optionalNumber: PropTypes.number,
|
||||
customProp: (() => null) as PropTypes.Validator<typeof uniqueType | undefined>
|
||||
customProp: (() => null) as PropTypes.Validator<typeof uniqueType | undefined>,
|
||||
component: PropTypes.elementType.isRequired
|
||||
};
|
||||
|
||||
const partialPropTypes = {
|
||||
@ -150,6 +153,7 @@ type ExtractFromOuterPropsMatch4 = Props extends ExtractedPropsFromOuterPropsWit
|
||||
type ExtractPropsMismatch = ExtractedPartialProps extends Props ? true : false;
|
||||
|
||||
PropTypes.checkPropTypes({ xs: PropTypes.array }, { xs: [] }, 'location', 'componentName');
|
||||
PropTypes.resetWarningCache();
|
||||
|
||||
// This would be the type that JSX sees
|
||||
type Defaultize<T, D> =
|
||||
|
||||
Loading…
Reference in New Issue
Block a user