From 1917a4122a16f8ff6c16ee09444724e56614665f Mon Sep 17 00:00:00 2001 From: Vincent Siao Date: Sun, 13 Mar 2016 21:54:40 -0700 Subject: [PATCH] [react] Add T param to React.DOM* types --- fixed-data-table/fixed-data-table-0.4.7.d.ts | 5 +- fixed-data-table/fixed-data-table.d.ts | 4 - jsnox/jsnox-tests.ts | 2 +- jsnox/jsnox.d.ts | 4 +- react-dnd/react-dnd-tests.ts | 2 +- react-holder/react-holder.d.ts | 2 +- .../react-input-calendar.d.ts | 1 - react-swf/react-swf.d.ts | 1 - react/react-addons-test-utils.d.ts | 4 +- react/react-dom.d.ts | 12 +- react/react-global-tests.ts | 8 +- react/react-tests.ts | 8 +- react/react.d.ts | 266 +++++++++--------- 13 files changed, 154 insertions(+), 165 deletions(-) diff --git a/fixed-data-table/fixed-data-table-0.4.7.d.ts b/fixed-data-table/fixed-data-table-0.4.7.d.ts index 1dc22dc3d..f681e5ea5 100644 --- a/fixed-data-table/fixed-data-table-0.4.7.d.ts +++ b/fixed-data-table/fixed-data-table-0.4.7.d.ts @@ -387,16 +387,13 @@ declare module FixedDataTable { } export class Table extends __React.Component { - render(): __React.DOMElement } export class Column extends __React.Component { - render(): __React.DOMElement } export class ColumnGroup extends __React.Component { - render(): __React.DOMElement } } declare module "fixed-data-table" { export = FixedDataTable; -} \ No newline at end of file +} diff --git a/fixed-data-table/fixed-data-table.d.ts b/fixed-data-table/fixed-data-table.d.ts index 843eb458e..c561abf41 100644 --- a/fixed-data-table/fixed-data-table.d.ts +++ b/fixed-data-table/fixed-data-table.d.ts @@ -483,16 +483,12 @@ declare module FixedDataTable { } export class Table extends __React.Component { - render(): __React.DOMElement } export class Column extends __React.Component { - render(): __React.DOMElement } export class ColumnGroup extends __React.Component { - render(): __React.DOMElement } export class Cell extends __React.Component { - render(): __React.DOMElement } } diff --git a/jsnox/jsnox-tests.ts b/jsnox/jsnox-tests.ts index 33e58720e..c1203f089 100644 --- a/jsnox/jsnox-tests.ts +++ b/jsnox/jsnox-tests.ts @@ -19,7 +19,7 @@ var clickHandler: React.MouseEventHandler // Tests with spec string function spec_string () { - var result: React.ReactHTMLElement + var result: React.ReactHTMLElement // just spec string result = $('div') diff --git a/jsnox/jsnox.d.ts b/jsnox/jsnox.d.ts index 22291956d..68687f719 100644 --- a/jsnox/jsnox.d.ts +++ b/jsnox/jsnox.d.ts @@ -31,7 +31,7 @@ declare module 'jsnox' { * @param children A single React node (string or ReactElement) or array of nodes. * Note that unlike with React itself, multiple children must be placed into an array. */ -

(specString: string, children: React.ReactNode): React.DOMElement

+

(specString: string, children: React.ReactNode): React.DOMElement /** * Renders an HTML element from the given spec string, with optional props @@ -42,7 +42,7 @@ declare module 'jsnox' { * @param children A single React node (string or ReactElement) or array of nodes. * Note that unlike with React itself, multiple children must be placed into an array. */ -

(specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.DOMElement

+

(specString: string, props?: React.HTMLAttributes, children?: React.ReactNode): React.DOMElement /** diff --git a/react-dnd/react-dnd-tests.ts b/react-dnd/react-dnd-tests.ts index 2c92b7b33..5be7832d5 100644 --- a/react-dnd/react-dnd-tests.ts +++ b/react-dnd/react-dnd-tests.ts @@ -262,7 +262,7 @@ module Board { }; render() { - var squares: React.DOMElement[] = []; + var squares: React.ReactHTMLElement[] = []; for (let i = 0; i < 64; i++) { squares.push(this._renderSquare(i)); } diff --git a/react-holder/react-holder.d.ts b/react-holder/react-holder.d.ts index f130239ad..b29cd0893 100644 --- a/react-holder/react-holder.d.ts +++ b/react-holder/react-holder.d.ts @@ -9,7 +9,7 @@ declare module "react-holder" { import React = __React; - interface ReactHolderProp extends React.HTMLProps { + interface ReactHolderProp extends React.HTMLAttributes { width: string | number; height: string | number; updateOnResize: boolean; diff --git a/react-input-calendar/react-input-calendar.d.ts b/react-input-calendar/react-input-calendar.d.ts index ec539382f..14b877c8d 100644 --- a/react-input-calendar/react-input-calendar.d.ts +++ b/react-input-calendar/react-input-calendar.d.ts @@ -76,7 +76,6 @@ declare module reactInputCalendar { } interface ReactInputCalendarState { } export class ReactInputCalendar extends __React.Component { - render(): __React.DOMElement; } } declare var ReactInputCalendar: typeof reactInputCalendar.ReactInputCalendar diff --git a/react-swf/react-swf.d.ts b/react-swf/react-swf.d.ts index 374ec876a..21921f8f9 100644 --- a/react-swf/react-swf.d.ts +++ b/react-swf/react-swf.d.ts @@ -113,7 +113,6 @@ declare module rswf { flashvars?: Object | string } export class ReactSWF extends __React.Component{ - render(): __React.DOMElement /** * Returns the Flash Player object DOM node. * Should be prefered over `React.findDOMNode`. diff --git a/react/react-addons-test-utils.d.ts b/react/react-addons-test-utils.d.ts index d71976ef6..0c29507a0 100644 --- a/react/react-addons-test-utils.d.ts +++ b/react/react-addons-test-utils.d.ts @@ -94,8 +94,8 @@ declare namespace __React { export var wheel: EventSimulator; } - export function renderIntoDocument( - element: DOMElement): Element; + export function renderIntoDocument( + element: DOMElement): T; export function renderIntoDocument

( element: ReactElement

): Component; export function renderIntoDocument>( diff --git a/react/react-dom.d.ts b/react/react-dom.d.ts index 80a0c604e..b4154cdc9 100644 --- a/react/react-dom.d.ts +++ b/react/react-dom.d.ts @@ -10,10 +10,10 @@ declare namespace __React { function findDOMNode(instance: ReactInstance): E; function findDOMNode(instance: ReactInstance): Element; - function render

( - element: DOMElement

, + function render

( + element: DOMElement, container: Element, - callback?: (element: Element) => any): Element; + callback?: (element: T) => any): T; function render( element: ClassicElement

, container: Element, @@ -31,11 +31,11 @@ declare namespace __React { function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; function unstable_batchedUpdates(callback: () => any): void; - function unstable_renderSubtreeIntoContainer

( + function unstable_renderSubtreeIntoContainer

( parentComponent: Component, - nextElement: DOMElement

, + element: DOMElement, container: Element, - callback?: (element: Element) => any): Element; + callback?: (element: T) => any): T; function unstable_renderSubtreeIntoContainer( parentComponent: Component, nextElement: ClassicElement

, diff --git a/react/react-global-tests.ts b/react/react-global-tests.ts index d4c8aa9f1..b943344a5 100644 --- a/react/react-global-tests.ts +++ b/react/react-global-tests.ts @@ -125,9 +125,9 @@ var classicFactory: React.ClassicFactory = var classicFactoryElement: React.ClassicElement = classicFactory(props); -var domFactory: React.DOMFactory = +var domFactory: React.DOMFactory = React.createFactory("foo"); -var domFactoryElement: React.DOMElement = +var domFactoryElement: React.DOMElement = domFactory(); // React.createElement @@ -135,7 +135,7 @@ var element: React.ReactElement = React.createElement(ModernComponent, props); var classicElement: React.ClassicElement = React.createElement(ClassicComponent, props); -var domElement: React.ReactHTMLElement = +var domElement: React.ReactHTMLElement = React.createElement("div"); // React.cloneElement @@ -143,7 +143,7 @@ var clonedElement: React.ReactElement = React.cloneElement(element, props); var clonedClassicElement: React.ClassicElement = React.cloneElement(classicElement, props); -var clonedDOMElement: React.ReactHTMLElement = +var clonedDOMElement: React.ReactHTMLElement = React.cloneElement(domElement); // React.render diff --git a/react/react-tests.ts b/react/react-tests.ts index 4a9c7de63..9a3ac5f50 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -170,9 +170,9 @@ var classicFactory: React.ClassicFactory = var classicFactoryElement: React.ClassicElement = classicFactory(props); -var domFactory: React.DOMFactory = +var domFactory: React.DOMFactory = React.createFactory("foo"); -var domFactoryElement: React.DOMElement = +var domFactoryElement: React.DOMElement = domFactory(); // React.createElement @@ -182,7 +182,7 @@ var statelessElement: React.ReactElement = React.createElement(StatelessComponent, props); var classicElement: React.ClassicElement = React.createElement(ClassicComponent, props); -var domElement: React.ReactHTMLElement = +var domElement: React.ReactHTMLElement = React.createElement("div"); // React.cloneElement @@ -194,7 +194,7 @@ var clonedStatelessElement: React.ReactElement = React.cloneElement(statelessElement, { foo: 44 }); var clonedClassicElement: React.ClassicElement = React.cloneElement(classicElement, props); -var clonedDOMElement: React.ReactHTMLElement = +var clonedDOMElement: React.ReactHTMLElement = React.cloneElement(domElement, { className: "clonedElement" }); diff --git a/react/react.d.ts b/react/react.d.ts index 3e55ca7eb..927a06ffa 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -31,17 +31,15 @@ declare namespace __React { ref: Ref>; } - interface DOMElement

extends ReactElement

{ + interface DOMElement

extends ReactElement

{ type: string; - ref: Ref; + ref: Ref; } - interface ReactHTMLElement extends DOMElement { - ref: Ref; + interface ReactHTMLElement extends DOMElement { } - interface ReactSVGElement extends DOMElement { - ref: Ref; + interface ReactSVGElement extends DOMElement { } // @@ -56,12 +54,15 @@ declare namespace __React { (props?: P & ClassAttributes>, ...children: ReactNode[]): ClassicElement

; } - interface DOMFactory

{ - (props?: P & ClassAttributes, ...children: ReactNode[]): DOMElement

; + interface DOMFactory

{ + (props?: P & ClassAttributes, ...children: ReactNode[]): DOMElement; } - type HTMLFactory = DOMFactory; - type SVGFactory = DOMFactory; + interface HTMLFactory extends DOMFactory { + } + + interface SVGFactory extends DOMFactory { + } // // React Nodes @@ -81,14 +82,15 @@ declare namespace __React { function createClass(spec: ComponentSpec): ClassicComponentClass

; - function createFactory

(type: string): DOMFactory

; + function createFactory

( + type: string): DOMFactory; function createFactory

(type: ClassicComponentClass

): ClassicFactory

; function createFactory

(type: ComponentClass

| StatelessComponent

): Factory

; function createElement

( type: string, - props?: P & ClassAttributes, - ...children: ReactNode[]): DOMElement

; + props?: P & ClassAttributes, + ...children: ReactNode[]): DOMElement; function createElement

( type: ClassicComponentClass

, props?: P & ClassAttributes>, @@ -98,14 +100,10 @@ declare namespace __React { props?: P & ClassAttributes>, ...children: ReactNode[]): ReactElement

; - function cloneElement( - element: ReactHTMLElement, - props?: HTMLAttributes & ClassAttributes, - ...children: ReactNode[]): ReactHTMLElement; - function cloneElement( - element: ReactSVGElement, - props?: SVGAttributes & ClassAttributes, - ...children: ReactNode[]): ReactSVGElement; + function cloneElement

( + element: DOMElement, + props?: P & ClassAttributes, + ...children: ReactNode[]): DOMElement; function cloneElement

( element: ClassicElement

, props?: Q & ClassAttributes>, @@ -2060,119 +2058,119 @@ declare namespace __React { 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; - hgroup: 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; + 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; + hgroup: 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: SVGFactory;