;
- type ReactNode = ReactChild | ReactFragment | boolean;
-
- //
- // Top Level API
- // ----------------------------------------------------------------------
-
- function createClass(spec: ComponentSpec
): ClassicComponentClass
;
-
- function createFactory
(type: string): DOMFactory
;
- function createFactory
(type: ClassicComponentClass
| string): ClassicFactory
;
- function createFactory
(type: ComponentClass
): Factory
;
-
- function createElement
(
- type: string,
- props?: P,
- ...children: ReactNode[]): DOMElement
;
- function createElement
(
- type: ClassicComponentClass
| string,
- props?: P,
- ...children: ReactNode[]): ClassicElement
;
- function createElement
(
- type: ComponentClass
,
- props?: P,
- ...children: ReactNode[]): ReactElement
;
-
- function cloneElement
(
- element: DOMElement
,
- props?: P,
- ...children: ReactNode[]): DOMElement
;
- function cloneElement
(
- element: ClassicElement
,
- props?: P,
- ...children: ReactNode[]): ClassicElement
;
- function cloneElement
(
- element: ReactElement
,
- props?: P,
- ...children: ReactNode[]): ReactElement
;
-
- function render
(
- element: DOMElement
,
- container: Element,
- callback?: () => any): DOMComponent
;
- function render
(
- element: ClassicElement
,
- container: Element,
- callback?: () => any): ClassicComponent
;
- function render
(
- element: ReactElement
,
- container: Element,
- callback?: () => any): Component
;
-
- function unmountComponentAtNode(container: Element): boolean;
- function renderToString(element: ReactElement): string;
- function renderToStaticMarkup(element: ReactElement): string;
- function isValidElement(object: {}): boolean;
- function initializeTouchEvents(shouldUseTouch: boolean): void;
-
- function findDOMNode(
- componentOrElement: Component | Element): TElement;
- function findDOMNode(
- componentOrElement: Component | Element): Element;
-
- var DOM: ReactDOM;
- var PropTypes: ReactPropTypes;
- var Children: ReactChildren;
-
- //
- // Component API
- // ----------------------------------------------------------------------
-
- // Base component for plain JS classes
- class Component implements ComponentLifecycle
{
- constructor(props?: P, context?: any);
- setState(f: (prevState: S, props: P) => S, callback?: () => any): void;
- setState(state: S, callback?: () => any): void;
- forceUpdate(): void;
- render(): JSX.Element;
- props: P;
- state: S;
- context: {};
- refs: {
- [key: string]: Component
- };
- }
-
- interface ClassicComponent extends Component
{
- replaceState(nextState: S, callback?: () => any): void;
- getDOMNode(): TElement;
- getDOMNode(): Element;
- isMounted(): boolean;
- getInitialState?(): S;
- setProps(nextProps: P, callback?: () => any): void;
- replaceProps(nextProps: P, callback?: () => any): void;
- }
-
- interface DOMComponent extends ClassicComponent
{
- tagName: string;
- }
-
- type HTMLComponent = DOMComponent;
- type SVGComponent = DOMComponent;
-
- interface ChildContextProvider {
- getChildContext(): CC;
- }
-
- //
- // Class Interfaces
- // ----------------------------------------------------------------------
-
- interface ComponentClass {
- new(props?: P, context?: any): Component
;
- propTypes?: ValidationMap
;
- contextTypes?: ValidationMap;
- childContextTypes?: ValidationMap;
- defaultProps?: P;
- }
-
- interface ClassicComponentClass extends ComponentClass
{
- new(props?: P, context?: any): ClassicComponent
;
- getDefaultProps?(): P;
- displayName?: string;
- }
-
- //
- // Component Specs and Lifecycle
- // ----------------------------------------------------------------------
-
- interface ComponentLifecycle
{
- componentWillMount?(): void;
- componentDidMount?(): void;
- componentWillReceiveProps?(nextProps: P, nextContext: any): void;
- shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean;
- componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void;
- componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void;
- componentWillUnmount?(): void;
- }
-
- interface Mixin
extends ComponentLifecycle
{
- mixins?: Mixin
;
- statics?: {
- [key: string]: any;
- };
-
- displayName?: string;
- propTypes?: ValidationMap;
- contextTypes?: ValidationMap;
- childContextTypes?: ValidationMap
-
- getDefaultProps?(): P;
- getInitialState?(): S;
- }
-
- interface ComponentSpec extends Mixin
{
- render(): ReactElement;
-
- [propertyName: string]: any;
- }
-
- //
- // Event System
- // ----------------------------------------------------------------------
-
- interface SyntheticEvent {
- bubbles: boolean;
- cancelable: boolean;
- currentTarget: EventTarget;
- defaultPrevented: boolean;
- eventPhase: number;
- isTrusted: boolean;
- nativeEvent: Event;
- preventDefault(): void;
- stopPropagation(): void;
- target: EventTarget;
- timeStamp: Date;
- type: string;
- }
-
- interface DragEvent extends SyntheticEvent {
- dataTransfer: DataTransfer;
- }
-
- interface ClipboardEvent extends SyntheticEvent {
- clipboardData: DataTransfer;
- }
-
- interface KeyboardEvent extends SyntheticEvent {
- altKey: boolean;
- charCode: number;
- ctrlKey: boolean;
- getModifierState(key: string): boolean;
- key: string;
- keyCode: number;
- locale: string;
- location: number;
- metaKey: boolean;
- repeat: boolean;
- shiftKey: boolean;
- which: number;
- }
-
- interface FocusEvent extends SyntheticEvent {
- relatedTarget: EventTarget;
- }
-
- interface FormEvent extends SyntheticEvent {
- }
-
- interface MouseEvent extends SyntheticEvent {
- altKey: boolean;
- button: number;
- buttons: number;
- clientX: number;
- clientY: number;
- ctrlKey: boolean;
- getModifierState(key: string): boolean;
- metaKey: boolean;
- pageX: number;
- pageY: number;
- relatedTarget: EventTarget;
- screenX: number;
- screenY: number;
- shiftKey: boolean;
- }
-
- interface TouchEvent extends SyntheticEvent {
- altKey: boolean;
- changedTouches: TouchList;
- ctrlKey: boolean;
- getModifierState(key: string): boolean;
- metaKey: boolean;
- shiftKey: boolean;
- targetTouches: TouchList;
- touches: TouchList;
- }
-
- interface UIEvent extends SyntheticEvent {
- detail: number;
- view: AbstractView;
- }
-
- interface WheelEvent extends SyntheticEvent {
- deltaMode: number;
- deltaX: number;
- deltaY: number;
- deltaZ: number;
- }
-
- //
- // Event Handler Types
- // ----------------------------------------------------------------------
-
- interface EventHandler {
- (event: E): void;
- }
-
- interface DragEventHandler extends EventHandler {}
- interface ClipboardEventHandler extends EventHandler {}
- interface KeyboardEventHandler extends EventHandler {}
- interface FocusEventHandler extends EventHandler {}
- interface FormEventHandler extends EventHandler {}
- interface MouseEventHandler extends EventHandler {}
- interface TouchEventHandler extends EventHandler {}
- interface UIEventHandler extends EventHandler {}
- interface WheelEventHandler extends EventHandler {}
-
- //
- // Props / DOM Attributes
- // ----------------------------------------------------------------------
-
- interface Props {
- children?: ReactNode;
- key?: string | number;
- ref?: string | ((component: T) => any);
- }
-
- interface DOMAttributes extends Props> {
- onCopy?: ClipboardEventHandler;
- onCut?: ClipboardEventHandler;
- onPaste?: ClipboardEventHandler;
- onKeyDown?: KeyboardEventHandler;
- onKeyPress?: KeyboardEventHandler;
- onKeyUp?: KeyboardEventHandler;
- onFocus?: FocusEventHandler;
- onBlur?: FocusEventHandler;
- onChange?: FormEventHandler;
- onInput?: FormEventHandler;
- onSubmit?: FormEventHandler;
- onClick?: MouseEventHandler;
- onDoubleClick?: MouseEventHandler;
- onDrag?: DragEventHandler;
- onDragEnd?: DragEventHandler;
- onDragEnter?: DragEventHandler;
- onDragExit?: DragEventHandler;
- onDragLeave?: DragEventHandler;
- onDragOver?: DragEventHandler;
- onDragStart?: DragEventHandler;
- onDrop?: DragEventHandler;
- onMouseDown?: MouseEventHandler;
- onMouseEnter?: MouseEventHandler;
- onMouseLeave?: MouseEventHandler;
- onMouseMove?: MouseEventHandler;
- onMouseOut?: MouseEventHandler;
- onMouseOver?: MouseEventHandler;
- onMouseUp?: MouseEventHandler;
- onTouchCancel?: TouchEventHandler;
- onTouchEnd?: TouchEventHandler;
- onTouchMove?: TouchEventHandler;
- onTouchStart?: TouchEventHandler;
- onScroll?: UIEventHandler;
- onWheel?: WheelEventHandler;
-
- dangerouslySetInnerHTML?: {
- __html: string;
- };
- }
-
- // This interface is not complete. Only properties accepting
- // unitless numbers are listed here (see CSSProperty.js in React)
- interface CSSProperties {
- boxFlex?: number;
- boxFlexGroup?: number;
- columnCount?: number;
- flex?: number | string;
- flexGrow?: number;
- flexShrink?: number;
- fontWeight?: number | string;
- lineClamp?: number;
- lineHeight?: number | string;
- opacity?: number;
- order?: number;
- orphans?: number;
- widows?: number;
- zIndex?: number;
- zoom?: number;
-
- fontSize?: number | string;
-
- // SVG-related properties
- fillOpacity?: number;
- strokeOpacity?: number;
- strokeWidth?: number;
-
- [propertyName: string]: string | number | boolean;
- }
-
- interface HTMLAttributes extends DOMAttributes {
- ref?: string | ((component: HTMLComponent) => void);
-
- accept?: string;
- acceptCharset?: string;
- accessKey?: string;
- action?: string;
- allowFullScreen?: boolean;
- allowTransparency?: boolean;
- alt?: string;
- async?: boolean;
- autoComplete?: boolean;
- autoFocus?: boolean;
- autoPlay?: boolean;
- cellPadding?: number | string;
- cellSpacing?: number | string;
- charSet?: string;
- checked?: boolean;
- classID?: string;
- className?: string;
- cols?: number;
- colSpan?: number;
- content?: string;
- contentEditable?: boolean;
- contextMenu?: string;
- controls?: any;
- coords?: string;
- crossOrigin?: string;
- data?: string;
- dateTime?: string;
- defaultChecked?: boolean;
- defaultValue?: string;
- defer?: boolean;
- dir?: string;
- disabled?: boolean;
- download?: any;
- draggable?: boolean;
- encType?: string;
- form?: string;
- formAction?: string;
- formEncType?: string;
- formMethod?: string;
- formNoValidate?: boolean;
- formTarget?: string;
- frameBorder?: number | string;
- headers?: string;
- height?: number | string;
- hidden?: boolean;
- high?: number;
- href?: string;
- hrefLang?: string;
- htmlFor?: string;
- httpEquiv?: string;
- icon?: string;
- id?: string;
- label?: string;
- lang?: string;
- list?: string;
- loop?: boolean;
- low?: number;
- manifest?: string;
- marginHeight?: number;
- marginWidth?: number;
- max?: number | string;
- maxLength?: number;
- media?: string;
- mediaGroup?: string;
- method?: string;
- min?: number | string;
- multiple?: boolean;
- muted?: boolean;
- name?: string;
- noValidate?: boolean;
- open?: boolean;
- optimum?: number;
- pattern?: string;
- placeholder?: string;
- poster?: string;
- preload?: string;
- radioGroup?: string;
- readOnly?: boolean;
- rel?: string;
- required?: boolean;
- role?: string;
- rows?: number;
- rowSpan?: number;
- sandbox?: string;
- scope?: string;
- scoped?: boolean;
- scrolling?: string;
- seamless?: boolean;
- selected?: boolean;
- shape?: string;
- size?: number;
- sizes?: string;
- span?: number;
- spellCheck?: boolean;
- src?: string;
- srcDoc?: string;
- srcSet?: string;
- start?: number;
- step?: number | string;
- style?: CSSProperties;
- tabIndex?: number;
- target?: string;
- title?: string;
- type?: string;
- useMap?: string;
- value?: string;
- width?: number | string;
- wmode?: string;
-
- // Non-standard Attributes
- autoCapitalize?: boolean;
- autoCorrect?: boolean;
- property?: string;
- itemProp?: string;
- itemScope?: boolean;
- itemType?: string;
- unselectable?: boolean;
- }
-
- interface SVGElementAttributes extends HTMLAttributes {
- viewBox?: string;
- preserveAspectRatio?: string;
- }
-
- interface SVGAttributes extends DOMAttributes {
- ref?: string | ((component: SVGComponent) => void);
-
- cx?: number | string;
- cy?: number | string;
- d?: string;
- dx?: number | string;
- dy?: number | string;
- fill?: string;
- fillOpacity?: number | string;
- fontFamily?: string;
- fontSize?: number | string;
- fx?: number | string;
- fy?: number | string;
- gradientTransform?: string;
- gradientUnits?: string;
- height?: number | string;
- markerEnd?: string;
- markerMid?: string;
- markerStart?: string;
- offset?: number | string;
- opacity?: number | string;
- patternContentUnits?: string;
- patternUnits?: string;
- points?: string;
- preserveAspectRatio?: string;
- r?: number | string;
- rx?: number | string;
- ry?: number | string;
- spreadMethod?: string;
- stopColor?: string;
- stopOpacity?: number | string;
- stroke?: string;
- strokeDasharray?: string;
- strokeLinecap?: string;
- strokeOpacity?: number | string;
- strokeWidth?: number | string;
- textAnchor?: string;
- transform?: string;
- version?: string;
- viewBox?: string;
- width?: number | string;
- x1?: number | string;
- x2?: number | string;
- x?: number | string;
- y1?: number | string;
- y2?: number | string
- y?: number | string;
- }
-
- //
- // React.DOM
- // ----------------------------------------------------------------------
-
- interface ReactDOM {
- // HTML
- a: HTMLFactory;
- abbr: HTMLFactory;
- address: HTMLFactory;
- area: HTMLFactory;
- article: HTMLFactory;
- aside: HTMLFactory;
- audio: HTMLFactory;
- b: HTMLFactory;
- base: HTMLFactory;
- bdi: HTMLFactory;
- bdo: HTMLFactory;
- big: HTMLFactory;
- blockquote: HTMLFactory;
- body: HTMLFactory;
- br: HTMLFactory;
- button: HTMLFactory;
- canvas: HTMLFactory;
- caption: HTMLFactory;
- cite: HTMLFactory;
- code: HTMLFactory;
- col: HTMLFactory;
- colgroup: HTMLFactory;
- data: HTMLFactory;
- datalist: HTMLFactory;
- dd: HTMLFactory;
- del: HTMLFactory;
- details: HTMLFactory;
- dfn: HTMLFactory;
- dialog: HTMLFactory;
- div: HTMLFactory;
- dl: HTMLFactory;
- dt: HTMLFactory;
- em: HTMLFactory;
- embed: HTMLFactory;
- fieldset: HTMLFactory;
- figcaption: HTMLFactory;
- figure: HTMLFactory;
- footer: HTMLFactory;
- form: HTMLFactory;
- h1: HTMLFactory;
- h2: HTMLFactory;
- h3: HTMLFactory;
- h4: HTMLFactory;
- h5: HTMLFactory;
- h6: HTMLFactory;
- head: HTMLFactory;
- header: HTMLFactory;
- hr: HTMLFactory;
- html: HTMLFactory;
- i: HTMLFactory;
- iframe: HTMLFactory;
- img: HTMLFactory;
- input: HTMLFactory;
- ins: HTMLFactory;
- kbd: HTMLFactory;
- keygen: HTMLFactory;
- label: HTMLFactory;
- legend: HTMLFactory;
- li: HTMLFactory;
- link: HTMLFactory;
- main: HTMLFactory;
- map: HTMLFactory;
- mark: HTMLFactory;
- menu: HTMLFactory;
- menuitem: HTMLFactory;
- meta: HTMLFactory;
- meter: HTMLFactory;
- nav: HTMLFactory;
- noscript: HTMLFactory;
- object: HTMLFactory;
- ol: HTMLFactory;
- optgroup: HTMLFactory;
- option: HTMLFactory;
- output: HTMLFactory;
- p: HTMLFactory;
- param: HTMLFactory;
- picture: HTMLFactory;
- pre: HTMLFactory;
- progress: HTMLFactory;
- q: HTMLFactory;
- rp: HTMLFactory;
- rt: HTMLFactory;
- ruby: HTMLFactory;
- s: HTMLFactory;
- samp: HTMLFactory;
- script: HTMLFactory;
- section: HTMLFactory;
- select: HTMLFactory;
- small: HTMLFactory;
- source: HTMLFactory;
- span: HTMLFactory;
- strong: HTMLFactory;
- style: HTMLFactory;
- sub: HTMLFactory;
- summary: HTMLFactory;
- sup: HTMLFactory;
- table: HTMLFactory;
- tbody: HTMLFactory;
- td: HTMLFactory;
- textarea: HTMLFactory;
- tfoot: HTMLFactory;
- th: HTMLFactory;
- thead: HTMLFactory;
- time: HTMLFactory;
- title: HTMLFactory;
- tr: HTMLFactory;
- track: HTMLFactory;
- u: HTMLFactory;
- ul: HTMLFactory;
- "var": HTMLFactory;
- video: HTMLFactory;
- wbr: HTMLFactory;
-
- // SVG
- svg: SVGElementFactory;
- circle: SVGFactory;
- defs: SVGFactory;
- ellipse: SVGFactory;
- g: SVGFactory;
- line: SVGFactory;
- linearGradient: SVGFactory;
- mask: SVGFactory;
- path: SVGFactory;
- pattern: SVGFactory;
- polygon: SVGFactory;
- polyline: SVGFactory;
- radialGradient: SVGFactory;
- rect: SVGFactory;
- stop: SVGFactory;
- text: SVGFactory;
- tspan: SVGFactory;
- }
-
- //
- // React.PropTypes
- // ----------------------------------------------------------------------
-
- interface Validator {
- (object: T, key: string, componentName: string): Error;
- }
-
- interface Requireable extends Validator {
- isRequired: Validator;
- }
-
- interface ValidationMap {
- [key: string]: Validator;
- }
-
- interface ReactPropTypes {
- any: Requireable;
- array: Requireable;
- bool: Requireable;
- func: Requireable;
- number: Requireable;
- object: Requireable;
- string: Requireable;
- node: Requireable;
- element: Requireable;
- instanceOf(expectedClass: {}): Requireable;
- oneOf(types: any[]): Requireable;
- oneOfType(types: Validator[]): Requireable;
- arrayOf(type: Validator): Requireable;
- objectOf(type: Validator): Requireable;
- shape(type: ValidationMap): Requireable;
- }
-
- //
- // React.Children
- // ----------------------------------------------------------------------
-
- interface ReactChildren {
- map(children: ReactNode, fn: (child: ReactChild, index: number) => T): { [key:string]: T };
- forEach(children: ReactNode, fn: (child: ReactChild, index: number) => any): void;
- count(children: ReactNode): number;
- only(children: ReactNode): ReactChild;
- }
-
- //
- // Browser Interfaces
- // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
- // ----------------------------------------------------------------------
-
- interface AbstractView {
- styleMedia: StyleMedia;
- document: Document;
- }
-
- interface Touch {
- identifier: number;
- target: EventTarget;
- screenX: number;
- screenY: number;
- clientX: number;
- clientY: number;
- pageX: number;
- pageY: number;
- }
-
- interface TouchList {
- [index: number]: Touch;
- length: number;
- item(index: number): Touch;
- identifiedTouch(identifier: number): Touch;
- }
-}
-
-declare module JSX {
- interface Element extends React.ReactElement { }
- interface ElementClass extends React.Component {
- render(): JSX.Element;
- }
- interface ElementAttributesProperty { props: {}; }
-
- interface IntrinsicElements {
- // HTML
- a: React.HTMLAttributes;
- abbr: React.HTMLAttributes;
- address: React.HTMLAttributes;
- area: React.HTMLAttributes;
- article: React.HTMLAttributes;
- aside: React.HTMLAttributes;
- audio: React.HTMLAttributes;
- b: React.HTMLAttributes;
- base: React.HTMLAttributes;
- bdi: React.HTMLAttributes;
- bdo: React.HTMLAttributes;
- big: React.HTMLAttributes;
- blockquote: React.HTMLAttributes;
- body: React.HTMLAttributes;
- br: React.HTMLAttributes;
- button: React.HTMLAttributes;
- canvas: React.HTMLAttributes;
- caption: React.HTMLAttributes;
- cite: React.HTMLAttributes;
- code: React.HTMLAttributes;
- col: React.HTMLAttributes;
- colgroup: React.HTMLAttributes;
- data: React.HTMLAttributes;
- datalist: React.HTMLAttributes;
- dd: React.HTMLAttributes;
- del: React.HTMLAttributes;
- details: React.HTMLAttributes;
- dfn: React.HTMLAttributes;
- dialog: React.HTMLAttributes;
- div: React.HTMLAttributes;
- dl: React.HTMLAttributes;
- dt: React.HTMLAttributes;
- em: React.HTMLAttributes;
- embed: React.HTMLAttributes;
- fieldset: React.HTMLAttributes;
- figcaption: React.HTMLAttributes;
- figure: React.HTMLAttributes;
- footer: React.HTMLAttributes;
- form: React.HTMLAttributes;
- h1: React.HTMLAttributes;
- h2: React.HTMLAttributes;
- h3: React.HTMLAttributes;
- h4: React.HTMLAttributes;
- h5: React.HTMLAttributes;
- h6: React.HTMLAttributes;
- head: React.HTMLAttributes;
- header: React.HTMLAttributes;
- hr: React.HTMLAttributes;
- html: React.HTMLAttributes;
- i: React.HTMLAttributes;
- iframe: React.HTMLAttributes;
- img: React.HTMLAttributes;
- input: React.HTMLAttributes;
- ins: React.HTMLAttributes;
- kbd: React.HTMLAttributes;
- keygen: React.HTMLAttributes;
- label: React.HTMLAttributes;
- legend: React.HTMLAttributes;
- li: React.HTMLAttributes;
- link: React.HTMLAttributes;
- main: React.HTMLAttributes;
- map: React.HTMLAttributes;
- mark: React.HTMLAttributes;
- menu: React.HTMLAttributes;
- menuitem: React.HTMLAttributes;
- meta: React.HTMLAttributes;
- meter: React.HTMLAttributes;
- nav: React.HTMLAttributes;
- noscript: React.HTMLAttributes;
- object: React.HTMLAttributes;
- ol: React.HTMLAttributes;
- optgroup: React.HTMLAttributes;
- option: React.HTMLAttributes;
- output: React.HTMLAttributes;
- p: React.HTMLAttributes;
- param: React.HTMLAttributes;
- picture: React.HTMLAttributes;
- pre: React.HTMLAttributes;
- progress: React.HTMLAttributes;
- q: React.HTMLAttributes;
- rp: React.HTMLAttributes;
- rt: React.HTMLAttributes;
- ruby: React.HTMLAttributes;
- s: React.HTMLAttributes;
- samp: React.HTMLAttributes;
- script: React.HTMLAttributes;
- section: React.HTMLAttributes;
- select: React.HTMLAttributes;
- small: React.HTMLAttributes;
- source: React.HTMLAttributes;
- span: React.HTMLAttributes;
- strong: React.HTMLAttributes;
- style: React.HTMLAttributes;
- sub: React.HTMLAttributes;
- summary: React.HTMLAttributes;
- sup: React.HTMLAttributes;
- table: React.HTMLAttributes;
- tbody: React.HTMLAttributes;
- td: React.HTMLAttributes;
- textarea: React.HTMLAttributes;
- tfoot: React.HTMLAttributes;
- th: React.HTMLAttributes;
- thead: React.HTMLAttributes;
- time: React.HTMLAttributes;
- title: React.HTMLAttributes;
- tr: React.HTMLAttributes;
- track: React.HTMLAttributes;
- u: React.HTMLAttributes;
- ul: React.HTMLAttributes;
- "var": React.HTMLAttributes;
- video: React.HTMLAttributes;
- wbr: React.HTMLAttributes;
-
- // SVG
- svg: React.SVGElementAttributes;
-
- circle: React.SVGAttributes;
- defs: React.SVGAttributes;
- ellipse: React.SVGAttributes;
- g: React.SVGAttributes;
- line: React.SVGAttributes;
- linearGradient: React.SVGAttributes;
- mask: React.SVGAttributes;
- path: React.SVGAttributes;
- pattern: React.SVGAttributes;
- polygon: React.SVGAttributes;
- polyline: React.SVGAttributes;
- radialGradient: React.SVGAttributes;
- rect: React.SVGAttributes;
- stop: React.SVGAttributes;
- text: React.SVGAttributes;
- tspan: React.SVGAttributes;
- }
-}
diff --git a/react/react-addons-global.d.ts b/react/react-namespace.ts
similarity index 98%
rename from react/react-addons-global.d.ts
rename to react/react-namespace.ts
index 508ae05225..99fba1e3de 100644
--- a/react/react-addons-global.d.ts
+++ b/react/react-namespace.ts
@@ -1,10 +1,13 @@
-// Type definitions for ReactWithAddons v0.13.1 (internal module)
+// Type definitions for React v0.13.3 (namespace)
// Project: http://facebook.github.io/react/
-// Definitions by: Asana , AssureSign
+// Definitions by: Asana , AssureSign , Microsoft
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-///
-declare module React {
+///
+
+import React = __React;
+
+declare namespace __React {
//
// React.addons
// ----------------------------------------------------------------------
@@ -275,4 +278,3 @@ declare module React {
unmount(): void;
}
}
-
diff --git a/react/react.d.ts b/react/react.d.ts
index a124e7b50d..98d19688be 100644
--- a/react/react.d.ts
+++ b/react/react.d.ts
@@ -1,9 +1,9 @@
-// Type definitions for React v0.13.1 (external module)
+// Type definitions for React v0.13.3
// Project: http://facebook.github.io/react/
// Definitions by: Asana , AssureSign , Microsoft
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare module __React {
+declare namespace __React {
//
// React Elements
// ----------------------------------------------------------------------
@@ -800,7 +800,1070 @@ declare module "react" {
export = __React;
}
-declare module JSX {
+declare module "react/addons" {
+ //
+ // React Elements
+ // ----------------------------------------------------------------------
+
+ type ReactType = ComponentClass | string;
+
+ interface ReactElement {
+ type: string | ComponentClass
;
+ props: P;
+ key: string | number;
+ ref: string | ((component: Component
) => any);
+ }
+
+ interface ClassicElement
extends ReactElement
{
+ type: string | ClassicComponentClass
;
+ ref: string | ((component: ClassicComponent
) => any);
+ }
+
+ interface DOMElement
extends ClassicElement
{
+ type: string;
+ ref: string | ((component: DOMComponent
) => any);
+ }
+
+ type HTMLElement = DOMElement;
+ type SVGElement = DOMElement;
+
+ //
+ // Factories
+ // ----------------------------------------------------------------------
+
+ interface Factory {
+ (props?: P, ...children: ReactNode[]): ReactElement
;
+ }
+
+ interface ClassicFactory
extends Factory
{
+ (props?: P, ...children: ReactNode[]): ClassicElement
;
+ }
+
+ interface DOMFactory
extends ClassicFactory
{
+ (props?: P, ...children: ReactNode[]): DOMElement
;
+ }
+
+ type HTMLFactory = DOMFactory;
+ type SVGFactory = DOMFactory;
+ type SVGElementFactory = DOMFactory;
+
+ //
+ // React Nodes
+ // http://facebook.github.io/react/docs/glossary.html
+ // ----------------------------------------------------------------------
+
+ type ReactText = string | number;
+ type ReactChild = ReactElement | ReactText;
+
+ // Should be Array but type aliases cannot be recursive
+ type ReactFragment = {} | Array;
+ type ReactNode = ReactChild | ReactFragment | boolean;
+
+ //
+ // Top Level API
+ // ----------------------------------------------------------------------
+
+ function createClass(spec: ComponentSpec
): ClassicComponentClass
;
+
+ function createFactory
(type: string): DOMFactory
;
+ function createFactory
(type: ClassicComponentClass
| string): ClassicFactory
;
+ function createFactory
(type: ComponentClass
): Factory
;
+
+ function createElement
(
+ type: string,
+ props?: P,
+ ...children: ReactNode[]): DOMElement
;
+ function createElement
(
+ type: ClassicComponentClass
| string,
+ props?: P,
+ ...children: ReactNode[]): ClassicElement
;
+ function createElement
(
+ type: ComponentClass
,
+ props?: P,
+ ...children: ReactNode[]): ReactElement
;
+
+ function cloneElement
(
+ element: DOMElement
,
+ props?: P,
+ ...children: ReactNode[]): DOMElement
;
+ function cloneElement
(
+ element: ClassicElement
,
+ props?: P,
+ ...children: ReactNode[]): ClassicElement
;
+ function cloneElement
(
+ element: ReactElement
,
+ props?: P,
+ ...children: ReactNode[]): ReactElement
;
+
+ function render
(
+ element: DOMElement
,
+ container: Element,
+ callback?: () => any): DOMComponent
;
+ function render
(
+ element: ClassicElement
,
+ container: Element,
+ callback?: () => any): ClassicComponent
;
+ function render
(
+ element: ReactElement
,
+ container: Element,
+ callback?: () => any): Component
;
+
+ function unmountComponentAtNode(container: Element): boolean;
+ function renderToString(element: ReactElement): string;
+ function renderToStaticMarkup(element: ReactElement): string;
+ function isValidElement(object: {}): boolean;
+ function initializeTouchEvents(shouldUseTouch: boolean): void;
+
+ function findDOMNode(
+ componentOrElement: Component | Element): TElement;
+ function findDOMNode(
+ componentOrElement: Component | Element): Element;
+
+ var DOM: ReactDOM;
+ var PropTypes: ReactPropTypes;
+ var Children: ReactChildren;
+
+ //
+ // Component API
+ // ----------------------------------------------------------------------
+
+ // Base component for plain JS classes
+ class Component implements ComponentLifecycle
{
+ constructor(props?: P, context?: any);
+ setState(f: (prevState: S, props: P) => S, callback?: () => any): void;
+ setState(state: S, callback?: () => any): void;
+ forceUpdate(): void;
+ render(): JSX.Element;
+ props: P;
+ state: S;
+ context: {};
+ refs: {
+ [key: string]: Component
+ };
+ }
+
+ interface ClassicComponent extends Component
{
+ replaceState(nextState: S, callback?: () => any): void;
+ getDOMNode(): TElement;
+ getDOMNode(): Element;
+ isMounted(): boolean;
+ getInitialState?(): S;
+ setProps(nextProps: P, callback?: () => any): void;
+ replaceProps(nextProps: P, callback?: () => any): void;
+ }
+
+ interface DOMComponent extends ClassicComponent
{
+ tagName: string;
+ }
+
+ type HTMLComponent = DOMComponent;
+ type SVGComponent = DOMComponent;
+
+ interface ChildContextProvider {
+ getChildContext(): CC;
+ }
+
+ //
+ // Class Interfaces
+ // ----------------------------------------------------------------------
+
+ interface ComponentClass {
+ new(props?: P, context?: any): Component
;
+ propTypes?: ValidationMap
;
+ contextTypes?: ValidationMap;
+ childContextTypes?: ValidationMap;
+ defaultProps?: P;
+ }
+
+ interface ClassicComponentClass extends ComponentClass
{
+ new(props?: P, context?: any): ClassicComponent
;
+ getDefaultProps?(): P;
+ displayName?: string;
+ }
+
+ //
+ // Component Specs and Lifecycle
+ // ----------------------------------------------------------------------
+
+ interface ComponentLifecycle
{
+ componentWillMount?(): void;
+ componentDidMount?(): void;
+ componentWillReceiveProps?(nextProps: P, nextContext: any): void;
+ shouldComponentUpdate?(nextProps: P, nextState: S, nextContext: any): boolean;
+ componentWillUpdate?(nextProps: P, nextState: S, nextContext: any): void;
+ componentDidUpdate?(prevProps: P, prevState: S, prevContext: any): void;
+ componentWillUnmount?(): void;
+ }
+
+ interface Mixin
extends ComponentLifecycle
{
+ mixins?: Mixin
;
+ statics?: {
+ [key: string]: any;
+ };
+
+ displayName?: string;
+ propTypes?: ValidationMap;
+ contextTypes?: ValidationMap;
+ childContextTypes?: ValidationMap
+
+ getDefaultProps?(): P;
+ getInitialState?(): S;
+ }
+
+ interface ComponentSpec extends Mixin
{
+ render(): ReactElement;
+
+ [propertyName: string]: any;
+ }
+
+ //
+ // Event System
+ // ----------------------------------------------------------------------
+
+ interface SyntheticEvent {
+ bubbles: boolean;
+ cancelable: boolean;
+ currentTarget: EventTarget;
+ defaultPrevented: boolean;
+ eventPhase: number;
+ isTrusted: boolean;
+ nativeEvent: Event;
+ preventDefault(): void;
+ stopPropagation(): void;
+ target: EventTarget;
+ timeStamp: Date;
+ type: string;
+ }
+
+ interface DragEvent extends SyntheticEvent {
+ dataTransfer: DataTransfer;
+ }
+
+ interface ClipboardEvent extends SyntheticEvent {
+ clipboardData: DataTransfer;
+ }
+
+ interface KeyboardEvent extends SyntheticEvent {
+ altKey: boolean;
+ charCode: number;
+ ctrlKey: boolean;
+ getModifierState(key: string): boolean;
+ key: string;
+ keyCode: number;
+ locale: string;
+ location: number;
+ metaKey: boolean;
+ repeat: boolean;
+ shiftKey: boolean;
+ which: number;
+ }
+
+ interface FocusEvent extends SyntheticEvent {
+ relatedTarget: EventTarget;
+ }
+
+ interface FormEvent extends SyntheticEvent {
+ }
+
+ interface MouseEvent extends SyntheticEvent {
+ altKey: boolean;
+ button: number;
+ buttons: number;
+ clientX: number;
+ clientY: number;
+ ctrlKey: boolean;
+ getModifierState(key: string): boolean;
+ metaKey: boolean;
+ pageX: number;
+ pageY: number;
+ relatedTarget: EventTarget;
+ screenX: number;
+ screenY: number;
+ shiftKey: boolean;
+ }
+
+ interface TouchEvent extends SyntheticEvent {
+ altKey: boolean;
+ changedTouches: TouchList;
+ ctrlKey: boolean;
+ getModifierState(key: string): boolean;
+ metaKey: boolean;
+ shiftKey: boolean;
+ targetTouches: TouchList;
+ touches: TouchList;
+ }
+
+ interface UIEvent extends SyntheticEvent {
+ detail: number;
+ view: AbstractView;
+ }
+
+ interface WheelEvent extends SyntheticEvent {
+ deltaMode: number;
+ deltaX: number;
+ deltaY: number;
+ deltaZ: number;
+ }
+
+ //
+ // Event Handler Types
+ // ----------------------------------------------------------------------
+
+ interface EventHandler {
+ (event: E): void;
+ }
+
+ interface DragEventHandler extends EventHandler {}
+ interface ClipboardEventHandler extends EventHandler {}
+ interface KeyboardEventHandler extends EventHandler {}
+ interface FocusEventHandler extends EventHandler {}
+ interface FormEventHandler extends EventHandler {}
+ interface MouseEventHandler extends EventHandler {}
+ interface TouchEventHandler extends EventHandler {}
+ interface UIEventHandler extends EventHandler {}
+ interface WheelEventHandler extends EventHandler {}
+
+ //
+ // Props / DOM Attributes
+ // ----------------------------------------------------------------------
+
+ interface Props {
+ children?: ReactNode;
+ key?: string | number;
+ ref?: string | ((component: T) => any);
+ }
+
+ interface DOMAttributes extends Props> {
+ onCopy?: ClipboardEventHandler;
+ onCut?: ClipboardEventHandler;
+ onPaste?: ClipboardEventHandler;
+ onKeyDown?: KeyboardEventHandler;
+ onKeyPress?: KeyboardEventHandler;
+ onKeyUp?: KeyboardEventHandler;
+ onFocus?: FocusEventHandler;
+ onBlur?: FocusEventHandler;
+ onChange?: FormEventHandler;
+ onInput?: FormEventHandler;
+ onSubmit?: FormEventHandler;
+ onClick?: MouseEventHandler;
+ onDoubleClick?: MouseEventHandler;
+ onDrag?: DragEventHandler;
+ onDragEnd?: DragEventHandler;
+ onDragEnter?: DragEventHandler;
+ onDragExit?: DragEventHandler;
+ onDragLeave?: DragEventHandler;
+ onDragOver?: DragEventHandler;
+ onDragStart?: DragEventHandler;
+ onDrop?: DragEventHandler;
+ onMouseDown?: MouseEventHandler;
+ onMouseEnter?: MouseEventHandler;
+ onMouseLeave?: MouseEventHandler;
+ onMouseMove?: MouseEventHandler;
+ onMouseOut?: MouseEventHandler;
+ onMouseOver?: MouseEventHandler;
+ onMouseUp?: MouseEventHandler;
+ onTouchCancel?: TouchEventHandler;
+ onTouchEnd?: TouchEventHandler;
+ onTouchMove?: TouchEventHandler;
+ onTouchStart?: TouchEventHandler;
+ onScroll?: UIEventHandler;
+ onWheel?: WheelEventHandler;
+
+ dangerouslySetInnerHTML?: {
+ __html: string;
+ };
+ }
+
+ // This interface is not complete. Only properties accepting
+ // unitless numbers are listed here (see CSSProperty.js in React)
+ interface CSSProperties {
+ boxFlex?: number;
+ boxFlexGroup?: number;
+ columnCount?: number;
+ flex?: number | string;
+ flexGrow?: number;
+ flexShrink?: number;
+ fontWeight?: number | string;
+ lineClamp?: number;
+ lineHeight?: number | string;
+ opacity?: number;
+ order?: number;
+ orphans?: number;
+ widows?: number;
+ zIndex?: number;
+ zoom?: number;
+
+ fontSize?: number | string;
+
+ // SVG-related properties
+ fillOpacity?: number;
+ strokeOpacity?: number;
+ strokeWidth?: number;
+
+ [propertyName: string]: string | number | boolean;
+ }
+
+ interface HTMLAttributes extends DOMAttributes {
+ ref?: string | ((component: HTMLComponent) => void);
+
+ accept?: string;
+ acceptCharset?: string;
+ accessKey?: string;
+ action?: string;
+ allowFullScreen?: boolean;
+ allowTransparency?: boolean;
+ alt?: string;
+ async?: boolean;
+ autoComplete?: boolean;
+ autoFocus?: boolean;
+ autoPlay?: boolean;
+ cellPadding?: number | string;
+ cellSpacing?: number | string;
+ charSet?: string;
+ checked?: boolean;
+ classID?: string;
+ className?: string;
+ cols?: number;
+ colSpan?: number;
+ content?: string;
+ contentEditable?: boolean;
+ contextMenu?: string;
+ controls?: any;
+ coords?: string;
+ crossOrigin?: string;
+ data?: string;
+ dateTime?: string;
+ defaultChecked?: boolean;
+ defaultValue?: string;
+ defer?: boolean;
+ dir?: string;
+ disabled?: boolean;
+ download?: any;
+ draggable?: boolean;
+ encType?: string;
+ form?: string;
+ formAction?: string;
+ formEncType?: string;
+ formMethod?: string;
+ formNoValidate?: boolean;
+ formTarget?: string;
+ frameBorder?: number | string;
+ headers?: string;
+ height?: number | string;
+ hidden?: boolean;
+ high?: number;
+ href?: string;
+ hrefLang?: string;
+ htmlFor?: string;
+ httpEquiv?: string;
+ icon?: string;
+ id?: string;
+ label?: string;
+ lang?: string;
+ list?: string;
+ loop?: boolean;
+ low?: number;
+ manifest?: string;
+ marginHeight?: number;
+ marginWidth?: number;
+ max?: number | string;
+ maxLength?: number;
+ media?: string;
+ mediaGroup?: string;
+ method?: string;
+ min?: number | string;
+ multiple?: boolean;
+ muted?: boolean;
+ name?: string;
+ noValidate?: boolean;
+ open?: boolean;
+ optimum?: number;
+ pattern?: string;
+ placeholder?: string;
+ poster?: string;
+ preload?: string;
+ radioGroup?: string;
+ readOnly?: boolean;
+ rel?: string;
+ required?: boolean;
+ role?: string;
+ rows?: number;
+ rowSpan?: number;
+ sandbox?: string;
+ scope?: string;
+ scoped?: boolean;
+ scrolling?: string;
+ seamless?: boolean;
+ selected?: boolean;
+ shape?: string;
+ size?: number;
+ sizes?: string;
+ span?: number;
+ spellCheck?: boolean;
+ src?: string;
+ srcDoc?: string;
+ srcSet?: string;
+ start?: number;
+ step?: number | string;
+ style?: CSSProperties;
+ tabIndex?: number;
+ target?: string;
+ title?: string;
+ type?: string;
+ useMap?: string;
+ value?: string;
+ width?: number | string;
+ wmode?: string;
+
+ // Non-standard Attributes
+ autoCapitalize?: boolean;
+ autoCorrect?: boolean;
+ property?: string;
+ itemProp?: string;
+ itemScope?: boolean;
+ itemType?: string;
+ unselectable?: boolean;
+ }
+
+ interface SVGElementAttributes extends HTMLAttributes {
+ viewBox?: string;
+ preserveAspectRatio?: string;
+ }
+
+ interface SVGAttributes extends DOMAttributes {
+ ref?: string | ((component: SVGComponent) => void);
+
+ cx?: number | string;
+ cy?: number | string;
+ d?: string;
+ dx?: number | string;
+ dy?: number | string;
+ fill?: string;
+ fillOpacity?: number | string;
+ fontFamily?: string;
+ fontSize?: number | string;
+ fx?: number | string;
+ fy?: number | string;
+ gradientTransform?: string;
+ gradientUnits?: string;
+ height?: number | string;
+ markerEnd?: string;
+ markerMid?: string;
+ markerStart?: string;
+ offset?: number | string;
+ opacity?: number | string;
+ patternContentUnits?: string;
+ patternUnits?: string;
+ points?: string;
+ preserveAspectRatio?: string;
+ r?: number | string;
+ rx?: number | string;
+ ry?: number | string;
+ spreadMethod?: string;
+ stopColor?: string;
+ stopOpacity?: number | string;
+ stroke?: string;
+ strokeDasharray?: string;
+ strokeLinecap?: string;
+ strokeOpacity?: number | string;
+ strokeWidth?: number | string;
+ textAnchor?: string;
+ transform?: string;
+ version?: string;
+ viewBox?: string;
+ width?: number | string;
+ x1?: number | string;
+ x2?: number | string;
+ x?: number | string;
+ y1?: number | string;
+ y2?: number | string
+ y?: number | string;
+ }
+
+ //
+ // React.DOM
+ // ----------------------------------------------------------------------
+
+ interface ReactDOM {
+ // HTML
+ a: HTMLFactory;
+ abbr: HTMLFactory;
+ address: HTMLFactory;
+ area: HTMLFactory;
+ article: HTMLFactory;
+ aside: HTMLFactory;
+ audio: HTMLFactory;
+ b: HTMLFactory;
+ base: HTMLFactory;
+ bdi: HTMLFactory;
+ bdo: HTMLFactory;
+ big: HTMLFactory;
+ blockquote: HTMLFactory;
+ body: HTMLFactory;
+ br: HTMLFactory;
+ button: HTMLFactory;
+ canvas: HTMLFactory;
+ caption: HTMLFactory;
+ cite: HTMLFactory;
+ code: HTMLFactory;
+ col: HTMLFactory;
+ colgroup: HTMLFactory;
+ data: HTMLFactory;
+ datalist: HTMLFactory;
+ dd: HTMLFactory;
+ del: HTMLFactory;
+ details: HTMLFactory;
+ dfn: HTMLFactory;
+ dialog: HTMLFactory;
+ div: HTMLFactory;
+ dl: HTMLFactory;
+ dt: HTMLFactory;
+ em: HTMLFactory;
+ embed: HTMLFactory;
+ fieldset: HTMLFactory;
+ figcaption: HTMLFactory;
+ figure: HTMLFactory;
+ footer: HTMLFactory;
+ form: HTMLFactory;
+ h1: HTMLFactory;
+ h2: HTMLFactory;
+ h3: HTMLFactory;
+ h4: HTMLFactory;
+ h5: HTMLFactory;
+ h6: HTMLFactory;
+ head: HTMLFactory;
+ header: HTMLFactory;
+ hr: HTMLFactory;
+ html: HTMLFactory;
+ i: HTMLFactory;
+ iframe: HTMLFactory;
+ img: HTMLFactory;
+ input: HTMLFactory;
+ ins: HTMLFactory;
+ kbd: HTMLFactory;
+ keygen: HTMLFactory;
+ label: HTMLFactory;
+ legend: HTMLFactory;
+ li: HTMLFactory;
+ link: HTMLFactory;
+ main: HTMLFactory;
+ map: HTMLFactory;
+ mark: HTMLFactory;
+ menu: HTMLFactory;
+ menuitem: HTMLFactory;
+ meta: HTMLFactory;
+ meter: HTMLFactory;
+ nav: HTMLFactory;
+ noscript: HTMLFactory;
+ object: HTMLFactory;
+ ol: HTMLFactory;
+ optgroup: HTMLFactory;
+ option: HTMLFactory;
+ output: HTMLFactory;
+ p: HTMLFactory;
+ param: HTMLFactory;
+ picture: HTMLFactory;
+ pre: HTMLFactory;
+ progress: HTMLFactory;
+ q: HTMLFactory;
+ rp: HTMLFactory;
+ rt: HTMLFactory;
+ ruby: HTMLFactory;
+ s: HTMLFactory;
+ samp: HTMLFactory;
+ script: HTMLFactory;
+ section: HTMLFactory;
+ select: HTMLFactory;
+ small: HTMLFactory;
+ source: HTMLFactory;
+ span: HTMLFactory;
+ strong: HTMLFactory;
+ style: HTMLFactory;
+ sub: HTMLFactory;
+ summary: HTMLFactory;
+ sup: HTMLFactory;
+ table: HTMLFactory;
+ tbody: HTMLFactory;
+ td: HTMLFactory;
+ textarea: HTMLFactory;
+ tfoot: HTMLFactory;
+ th: HTMLFactory;
+ thead: HTMLFactory;
+ time: HTMLFactory;
+ title: HTMLFactory;
+ tr: HTMLFactory;
+ track: HTMLFactory;
+ u: HTMLFactory;
+ ul: HTMLFactory;
+ "var": HTMLFactory;
+ video: HTMLFactory;
+ wbr: HTMLFactory;
+
+ // SVG
+ svg: SVGElementFactory;
+ circle: SVGFactory;
+ defs: SVGFactory;
+ ellipse: SVGFactory;
+ g: SVGFactory;
+ line: SVGFactory;
+ linearGradient: SVGFactory;
+ mask: SVGFactory;
+ path: SVGFactory;
+ pattern: SVGFactory;
+ polygon: SVGFactory;
+ polyline: SVGFactory;
+ radialGradient: SVGFactory;
+ rect: SVGFactory;
+ stop: SVGFactory;
+ text: SVGFactory;
+ tspan: SVGFactory;
+ }
+
+ //
+ // React.PropTypes
+ // ----------------------------------------------------------------------
+
+ interface Validator {
+ (object: T, key: string, componentName: string): Error;
+ }
+
+ interface Requireable extends Validator {
+ isRequired: Validator