From 7bb2b48cd26bf3c83ab63e038c4753b2137bc04b Mon Sep 17 00:00:00 2001 From: jbrantly Date: Mon, 19 Jan 2015 14:59:04 -0500 Subject: [PATCH] Change most uses of ComponentClass

to a type that represents the class This more accurately reflects that createClass returns a class, not an instance of a class. This will be more important as React v0.13 is released which supports using ES6 classes as components. --- react/react-tests.ts | 2 +- react/react.d.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/react/react-tests.ts b/react/react-tests.ts index 338e483a0c..a6040f6820 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -32,7 +32,7 @@ var INPUT_REF: string = "input"; // Top-Level API // -------------------------------------------------------------------------- -var reactClass: React.ComponentClass = React.createClass({ +var reactClass = React.createClass({ getDefaultProps: () => { return { hello: undefined, diff --git a/react/react.d.ts b/react/react.d.ts index 2b75bb3fd5..bf66534d2b 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -41,7 +41,11 @@ declare module React { propTypes?: ValidationMap

; } - interface ComponentClass

extends ComponentStatics

{ + interface ComponentClassType

extends ComponentStatics

{ + new (): ComponentClass

; + } + + interface ComponentClass

{ // Deprecated in 0.12. See http://fb.me/react-legacyfactory // new(props: P): ReactElement

; // (props: P): ReactElement

; @@ -63,9 +67,9 @@ declare module React { // ---------------------------------------------------------------------- interface TopLevelAPI { - createClass

(spec: ComponentSpec): ComponentClass

; + createClass

(spec: ComponentSpec): ComponentClassType

; createElement

(type: any/*ReactType*/, props: P, ...children: any/*ReactNode*/[]): ReactElement

; - createFactory

(componentClass: ComponentClass

): ComponentFactory

; + createFactory

(componentClass: ComponentClassType

): ComponentFactory

; render

(element: ReactElement

, container: Element, callback?: () => any): Component

; unmountComponentAtNode(container: Element): boolean; renderToString(element: ReactElement): string; @@ -670,9 +674,6 @@ declare module React { transitionLeave?: boolean; } - interface CSSTransitionGroup extends ComponentClass {} - interface TransitionGroup extends ComponentClass {} - // // React.addons (Mixins) // ---------------------------------------------------------------------- @@ -873,10 +874,10 @@ declare module React { interface AddonsExports extends Exports { addons: { - CSSTransitionGroup: CSSTransitionGroup; + CSSTransitionGroup: ComponentClassType; LinkedStateMixin: LinkedStateMixin; PureRenderMixin: PureRenderMixin; - TransitionGroup: TransitionGroup; + TransitionGroup: ComponentClassType; batchedUpdates(callback: (a: A, b: B) => any, a: A, b: B): void; batchedUpdates(callback: (a: A) => any, a: A): void;