From bdfdaf7fef18e267ed2df2e37e4bf81685706eb2 Mon Sep 17 00:00:00 2001 From: Ross Pokorny Date: Tue, 24 Sep 2019 17:00:12 -0400 Subject: [PATCH] [react] Add propTypes to ForwardRefExoticComponent (#38337) * Add propTypes to ForwardRefExoticComponent * Add test --- types/react/index.d.ts | 1 + types/react/test/index.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index fa5d1753066c07..4ab1e67ed7a16b 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -725,6 +725,7 @@ declare namespace React { // but can be given its own specific name interface ForwardRefExoticComponent

extends NamedExoticComponent

{ defaultProps?: Partial

; + propTypes?: WeakValidationMap

; } function forwardRef(Component: RefForwardingComponent): ForwardRefExoticComponent & RefAttributes>; diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 8787c19d629888..7ab3cc4d33317e 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -402,6 +402,9 @@ const ForwardingRefComponent = React.forwardRef((props: {}, ref: React.Ref = {}; +ForwardingRefComponent.propTypes = ForwardingRefComponentPropTypes; + function RefCarryingComponent() { const ref: React.RefObject = React.createRef(); // Without the explicit type argument, TypeScript infers `{ref: React.RefObject}`