DefinitelyTyped/types/react-is/index.d.ts
Avi Vahl 3bd1232485 [react-is] Initial package typings (#25176)
* [react-is] Initial typings for package
React introduced the react-is for assertions on elements and element types.

I took the README and tests and created the matching ts types.

* Add TypeScript 2.6 comment
this package uses @types/react, and it requires 2.6 or above.

* Match strictFunctionTypes config of react

* Remove unneeded generics
per https://github.com/Microsoft/dtslint/blob/master/docs/no-unnecessary-generics.md

React uses this pattern (providing the Props interface via generics) and turned off the linting. We'll use the default lint options and `any` props.

* Use ReactType instead of an explicit union

* Cleanup unused imports
2018-04-21 05:36:06 +12:00

27 lines
1.0 KiB
TypeScript

// Type definitions for react-is 16.3
// Project: https://reactjs.org/
// Definitions by: Avi Vahl <https://github.com/AviVahl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
export as namespace ReactIs;
import { ReactElement, ReactType } from 'react';
export function typeOf(value: any): symbol | undefined;
export function isValidElementType(value: any): value is ReactType;
export function isContextConsumer(value: any): value is ReactElement<any>;
export function isContextProvider(value: any): value is ReactElement<any>;
export function isElement(value: any): value is ReactElement<any>;
export function isFragment(value: any): value is ReactElement<any>;
export function isPortal(value: any): value is ReactElement<any>;
export function isStrictMode(value: any): value is ReactElement<any>;
export const ContextProvider: symbol;
export const ContextConsumer: symbol;
export const Element: symbol;
export const Fragment: symbol;
export const Portal: symbol;
export const StrictMode: symbol;