From c41fd250fa3f8f5b16c40b2ee838109aeea45509 Mon Sep 17 00:00:00 2001 From: Christian Chown Date: Sun, 23 Sep 2018 10:11:24 +0100 Subject: [PATCH 1/2] [react-is] Add AsyncMode, ForwardRef and Profiler --- types/react-is/index.d.ts | 10 ++++++++-- types/react-is/react-is-tests.tsx | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/types/react-is/index.d.ts b/types/react-is/index.d.ts index b0a1fd1099..419cb62e43 100644 --- a/types/react-is/index.d.ts +++ b/types/react-is/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-is 16.3 +// Type definitions for react-is 16.5 // Project: https://reactjs.org/ // Definitions by: Avi Vahl +// Christian Chown // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -10,17 +11,22 @@ import { ReactElement, ReactType } from 'react'; export function typeOf(value: any): symbol | undefined; export function isValidElementType(value: any): value is ReactType; - +export function isAsyncMode(value: any): value is ReactType; export function isContextConsumer(value: any): value is ReactElement; export function isContextProvider(value: any): value is ReactElement; export function isElement(value: any): value is ReactElement; +export function isForwardRef(value: any): value is ReactElement; export function isFragment(value: any): value is ReactElement; +export function isProfiler(value: any): value is ReactElement; export function isPortal(value: any): value is ReactElement; export function isStrictMode(value: any): value is ReactElement; +export const AsyncMode: symbol; export const ContextProvider: symbol; export const ContextConsumer: symbol; export const Element: symbol; +export const ForwardRef: symbol; export const Fragment: symbol; export const Portal: symbol; +export const Profiler: symbol; export const StrictMode: symbol; diff --git a/types/react-is/react-is-tests.tsx b/types/react-is/react-is-tests.tsx index a03ad7b534..18ae0c4a26 100644 --- a/types/react-is/react-is-tests.tsx +++ b/types/react-is/react-is-tests.tsx @@ -72,3 +72,7 @@ ReactIs.typeOf(123) === undefined; ReactIs.typeOf({}) === undefined; ReactIs.typeOf(null) === undefined; ReactIs.typeOf(undefined) === undefined; + +// ForwardRef +const forwardRef = React.forwardRef((props, ref) =>
); +ReactIs.isForwardRef(forwardRef); // true From 29ebc13c7c268d049721428358b2f3d0c5eae1a6 Mon Sep 17 00:00:00 2001 From: Christian Chown Date: Sun, 23 Sep 2018 22:13:02 +0100 Subject: [PATCH 2/2] Correct type guard for isAsyncMode --- types/react-is/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-is/index.d.ts b/types/react-is/index.d.ts index 419cb62e43..35d4b4db12 100644 --- a/types/react-is/index.d.ts +++ b/types/react-is/index.d.ts @@ -11,7 +11,7 @@ import { ReactElement, ReactType } from 'react'; export function typeOf(value: any): symbol | undefined; export function isValidElementType(value: any): value is ReactType; -export function isAsyncMode(value: any): value is ReactType; +export function isAsyncMode(value: any): value is ReactElement; export function isContextConsumer(value: any): value is ReactElement; export function isContextProvider(value: any): value is ReactElement; export function isElement(value: any): value is ReactElement;