diff --git a/react/react.d.ts b/react/react.d.ts index 74a7c26ef3..63877475c5 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -1,9 +1,59 @@ -// Type definitions for pg +// Type definitions for React 0.11.2 // Project: http://facebook.github.io/react/ // Definitions by: Asana // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "react" { + export function createClass(specification: Specification): Factory

; + export function renderComponent(component: Descriptor, container: Element, callback?: () => void): void; + export function unmountComponentAtNode(container: Element): boolean; + export function renderComponentToString(component: Descriptor): string; + export function renderComponentToStaticMarkup(component: Descriptor): string; + export function isValidClass(factory: Factory): boolean; + export function isValidComponent(component: Descriptor): boolean; + + export interface Descriptor

{ + props: P; + } + + export interface Factory

{ + (properties?: P, ...children: any[]): Descriptor

; + } + + export interface Mixin { + componentWillMount?(): void; + componentDidMount?(): void; + componentWillReceiveProps?(nextProps: P): void; + shouldComponentUpdate?(nextProps: P, nextState: S): boolean; + componentWillUpdate?(nextProps: P, nextState: S): void; + componentDidUpdate?(prevProps: P, prevState: S): void; + componentWillUnmount?(): void; + } + + export interface Specification extends Mixin { + displayName?: string; + mixins?: Mixin[]; + statics?: { + [key: string]: Function + }; + // TODO: Do the correct type definition + propTypes?: Object; + getDefaultProps?(): P; + getInitialState?(): S; + render(): Descriptor; + } + + export interface Component { + setState(nextState: S, callback?: () => void): void; + replaceState(nextState: S, callback?: () => void): void; + forceUpdate(callback?: () => void): void; + getDomNode(): Element; + isMounted(): boolean; + transferPropsTo(target: Factory

): Descriptor

; + setProps(nextProps: P, callback?: () => void): void; + replaceProps(nextProps: P, callback?: () => void): void; + } + // Browser Interfaces // Taken from https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts interface AbstractView {