DefinitelyTyped/types/react-is-deprecated/index.d.ts
Ferdy Budhidharma ffc8351127 [prop-types] use conditional types for better prop type inference (#27378)
* feat(prop-types): use conditional types for better prop type inference

* fix(tests): fix publish tests

* fix(prop-types): add custom prop validator, and switch requireables

* fix(test): revert ReactFragment change

* fix(prop-types): namespace imports from react like a good boy

* CR changes

* actually remove param from validator

* remove anyvalidationmap

* everyday i'm test...ering

* SEMICOLONS WHY

* retain null in undefaultize
2018-07-21 13:41:15 +01:00

38 lines
1.7 KiB
TypeScript

// Type definitions for react-is-deprecated v0.1.2
// Project: https://github.com/Aweary/react-is-deprecated
// Definitions by: Sean Kelley <https://github.com/seansfkelley>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
declare module 'react-is-deprecated' {
import { Validator, Requireable, ValidationMap, ReactPropTypes } from 'react';
export function deprecate<T>(validator: Validator<T>, message: string): Validator<T>;
interface Deprecatable<T> {
isDeprecated: (message: string) => Validator<T>;
}
// Unfortunately this copy-paste must happen -- I can't just take PropTypes and programmatically
// define a version that intersects in the Deprecatable interface into the keys.
interface DeprecatablePropTypes {
any: Requireable<any> & Deprecatable<any>;
array: Requireable<any> & Deprecatable<any>;
bool: Requireable<any> & Deprecatable<any>;
func: Requireable<any> & Deprecatable<any>;
number: Requireable<any> & Deprecatable<any>;
object: Requireable<any> & Deprecatable<any>;
string: Requireable<any> & Deprecatable<any>;
node: Requireable<any> & Deprecatable<any>;
element: Requireable<any> & Deprecatable<any>;
instanceOf(expectedClass: {}): Requireable<any> & Deprecatable<any>;
oneOf(types: any[]): Requireable<any> & Deprecatable<any>;
oneOfType(types: Validator<any>[]): Requireable<any> & Deprecatable<any>;
arrayOf(type: Validator<any>): Requireable<any> & Deprecatable<any>;
objectOf(type: Validator<any>): Requireable<any> & Deprecatable<any>;
shape(type: ValidationMap<any>): Requireable<any> & Deprecatable<any>;
}
export function addIsDeprecated(propTypes: ReactPropTypes): DeprecatablePropTypes;
}