diff --git a/types/react/global.d.ts b/types/react/global.d.ts index 23af6dc7a3..c647e7239b 100644 --- a/types/react/global.d.ts +++ b/types/react/global.d.ts @@ -1,5 +1,5 @@ /* -React projects that don't include the DOM library need these interfaces to compile. +React projects that don't include the DOM library these interfaces need to compile. React Native applications use React, but there is no DOM available. The JavaScript runtime is ES6/ES2015 only. These definitions allow such projects to compile with only `--lib ES6`. */ @@ -33,6 +33,7 @@ interface HTMLBodyElement extends HTMLElement { } interface HTMLBRElement extends HTMLElement { } interface HTMLButtonElement extends HTMLElement { } interface HTMLCanvasElement extends HTMLElement { } +interface HTMLDialogElement extends HTMLElement { } interface HTMLDivElement extends HTMLElement { } interface HTMLDListElement extends HTMLElement { } interface HTMLEmbedElement extends HTMLElement { } @@ -175,3 +176,5 @@ interface SVGTextPathElement extends SVGElement { } interface SVGTSpanElement extends SVGElement { } interface SVGUseElement extends SVGElement { } interface SVGViewElement extends SVGElement { } + +interface TouchList { } diff --git a/types/react/index.d.ts b/types/react/index.d.ts index c39e5eeb6c..24884576ff 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -14,6 +14,7 @@ // Stéphane Goetz // Rich Seviora // Josh Rutherford +// Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/react/test/index.ts b/types/react/test/index.ts index 757a1da669..e0e4a09065 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -44,7 +44,7 @@ const props: Props & React.ClassAttributes<{}> = { foo: 42 }; -const container: Element = document.createElement("div"); +declare const container: Element; // // Top-Level API @@ -226,9 +226,9 @@ const clonedSvgElement: React.ReactSVGElement = const component: ModernComponent = ReactDOM.render(element, container); const componentNullContainer: ModernComponent = ReactDOM.render(element, null); -const componentElementOrNull: ModernComponent = ReactDOM.render(element, document.getElementById("anelement")); +const componentElementOrNull: ModernComponent = ReactDOM.render(element, container); const componentNoState: ModernComponentNoState = ReactDOM.render(elementNoState, container); -const componentNoStateElementOrNull: ModernComponentNoState = ReactDOM.render(elementNoState, document.getElementById("anelement")); +const componentNoStateElementOrNull: ModernComponentNoState = ReactDOM.render(elementNoState, container); const domComponent: Element = ReactDOM.render(domElement, container); // Other Top-Level API @@ -313,7 +313,7 @@ const htmlAttr: React.HTMLProps = { event.stopPropagation(); }, onAnimationStart: event => { - console.log(event.currentTarget.className); + const currentTarget: EventTarget & HTMLElement = event.currentTarget; }, dangerouslySetInnerHTML: { __html: "STRONG" @@ -624,7 +624,7 @@ if (TestUtils.isElementOfType(emptyElement2, StatelessComponent)) { } if (TestUtils.isDOMComponent(container)) { - container.getAttribute("className"); + const reassignedContainer: Element = container; } else if (TestUtils.isCompositeComponent(new ModernComponent({ hello: 'hi', foo: 3 }))) { new ModernComponent({ hello: 'hi', foo: 3 }).props; } @@ -670,7 +670,9 @@ class SyntheticEventTargetValue extends React.Component<{}, { value: string }> { render() { return DOM.textarea({ value: this.state.value, - onChange: e => this.setState({ value: e.target.value }) + onChange: e => { + const target: HTMLTextAreaElement = e.target; + } }); } } @@ -678,7 +680,7 @@ class SyntheticEventTargetValue extends React.Component<{}, { value: string }> { DOM.input({ onChange: event => { // `event.target` is guaranteed to be HTMLInputElement - event.target.value; + const target: HTMLInputElement = event.target; } }); diff --git a/types/react/tsconfig.json b/types/react/tsconfig.json index 1b79768acc..b999a338b3 100644 --- a/types/react/tsconfig.json +++ b/types/react/tsconfig.json @@ -8,8 +8,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": false,