From 51e7287c86e23281e6f45efa68becd574032cea2 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 29 Jun 2017 13:31:52 +0200 Subject: [PATCH 1/3] React.SFC<...> | React.ComponentClass<...> => React.ComponentType<...> --- types/react-router-config/index.d.ts | 2 +- types/react-router/index.d.ts | 4 ++-- types/rrc/index.d.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-router-config/index.d.ts b/types/react-router-config/index.d.ts index 8497b0d4b8..7644b8f062 100644 --- a/types/react-router-config/index.d.ts +++ b/types/react-router-config/index.d.ts @@ -14,7 +14,7 @@ export interface RouteConfigComponentProps extends RouteComponentProps { export interface RouteConfig { location?: Location; - component?: React.SFC | void> | React.ComponentClass | void>; + component?: React.ComponentType | void>; path?: string; exact?: boolean; strict?: boolean; diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 72afa50e3b..2f38251db8 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -64,7 +64,7 @@ export interface RouteComponentProps

{ export interface RouteProps { location?: H.Location; - component?: React.SFC | undefined> | React.ComponentClass | undefined>; + component?: React.ComponentType | undefined>; render?: ((props: RouteComponentProps) => React.ReactNode); children?: ((props: RouteComponentProps) => React.ReactNode) | React.ReactNode; path?: string; @@ -99,4 +99,4 @@ export interface match

{ } export function matchPath

(pathname: string, props: RouteProps): match

| null; -export function withRouter

(component: React.SFC & P> | React.ComponentClass & P>): React.ComponentClass

; +export function withRouter

(component: React.ComponentType & P>): React.ComponentClass

; diff --git a/types/rrc/index.d.ts b/types/rrc/index.d.ts index 6a56baf3fc..891ceeaa64 100644 --- a/types/rrc/index.d.ts +++ b/types/rrc/index.d.ts @@ -22,7 +22,7 @@ export interface WithScrollOptions { alignToTop?: boolean; } -export type ComponentConstructor = React.ComponentClass | React.SFC; +export type ComponentConstructor = React.ComponentType; export function withScroll(component: ComponentConstructor | undefined>, options?: WithScrollOptions) : ComponentConstructor | undefined>; From 552051f56f4e46da801297a8631447f97aaade0c Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 29 Jun 2017 13:54:42 +0200 Subject: [PATCH 2/3] Default props should be {}, not undefined or void --- types/react-router-config/index.d.ts | 2 +- types/react-router/index.d.ts | 2 +- .../PreventingTransitions.tsx | 2 +- types/rrc/index.d.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/react-router-config/index.d.ts b/types/react-router-config/index.d.ts index 7644b8f062..2040a8a721 100644 --- a/types/react-router-config/index.d.ts +++ b/types/react-router-config/index.d.ts @@ -14,7 +14,7 @@ export interface RouteConfigComponentProps extends RouteComponentProps { export interface RouteConfig { location?: Location; - component?: React.ComponentType | void>; + component?: React.ComponentType | {}>; path?: string; exact?: boolean; strict?: boolean; diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 2f38251db8..cfd0b20c66 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -64,7 +64,7 @@ export interface RouteComponentProps

{ export interface RouteProps { location?: H.Location; - component?: React.ComponentType | undefined>; + component?: React.ComponentType | {}>; render?: ((props: RouteComponentProps) => React.ReactNode); children?: ((props: RouteComponentProps) => React.ReactNode) | React.ReactNode; path?: string; diff --git a/types/react-router/test/examples-from-react-router-website/PreventingTransitions.tsx b/types/react-router/test/examples-from-react-router-website/PreventingTransitions.tsx index bd5d76ae2b..9f1858c89f 100644 --- a/types/react-router/test/examples-from-react-router-website/PreventingTransitions.tsx +++ b/types/react-router/test/examples-from-react-router-website/PreventingTransitions.tsx @@ -22,7 +22,7 @@ const PreventingTransitionsExample = () => ( ); -class Form extends React.Component { +class Form extends React.Component<{}, {isBlocking: boolean}> { state = { isBlocking: false }; diff --git a/types/rrc/index.d.ts b/types/rrc/index.d.ts index 891ceeaa64..f4ef84e568 100644 --- a/types/rrc/index.d.ts +++ b/types/rrc/index.d.ts @@ -24,8 +24,8 @@ export interface WithScrollOptions { export type ComponentConstructor = React.ComponentType; -export function withScroll(component: ComponentConstructor | undefined>, options?: WithScrollOptions) - : ComponentConstructor | undefined>; +export function withScroll(component: ComponentConstructor | {}>, options?: WithScrollOptions) + : ComponentConstructor | {}>; export type RouteConfiguration = RouteProps & { inject?: { [key: string]: any } }; From 5addbe9b7270c558b5ef26d4bfd84b3df08e4427 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 29 Jun 2017 13:55:50 +0200 Subject: [PATCH 3/3] React.ComponentType

=> React.ComponentType

--- types/react/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 577959ae7b..de21376a94 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -35,7 +35,7 @@ declare namespace React { // ---------------------------------------------------------------------- type ReactType = string | ComponentType; - type ComponentType

= ComponentClass

| StatelessComponent

; + type ComponentType

= ComponentClass

| StatelessComponent

; type Key = string | number; type Ref = string | ((instance: T | null) => any);