From 9050d36d5763beabb1a642819dd24d61cccb3ffe Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 17 Mar 2020 23:28:07 +1100 Subject: std: Provide types for React and ReactDOM (#4376) Introduces `std/types` which is designed to provide types for common libraries that are compatible with Deno. --- std/types/react-dom.d.ts | 125 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 std/types/react-dom.d.ts (limited to 'std/types/react-dom.d.ts') diff --git a/std/types/react-dom.d.ts b/std/types/react-dom.d.ts new file mode 100644 index 000000000..f135197f2 --- /dev/null +++ b/std/types/react-dom.d.ts @@ -0,0 +1,125 @@ +// These types are adapted from +// https://github.com/DefinitelyTyped/DefinitelyTyped to work under Deno. +// +// Type definitions for React (react-dom) 16.9 +// Project: http://facebook.github.io/react/ +// Definitions by: Asana +// AssureSign +// Microsoft +// MartynasZilinskas +// Josh Rutherford +// Jessica Franco +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +// NOTE: Users of the `experimental` builds of React should add a reference +// to 'react-dom/experimental' in their project. See experimental.d.ts's top comment +// for reference and documentation on how exactly to do it. + +/* eslint-disable */ + +export as namespace ReactDOM; + +import { + ReactInstance, + Component, + ComponentState, + ReactElement, + SFCElement, + CElement, + DOMAttributes, + DOMElement, + ReactNode, + ReactPortal +} from "./react.d.ts"; + +export function findDOMNode( + instance: ReactInstance | null | undefined +): Element | null | Text; +export function unmountComponentAtNode(container: Element): boolean; + +export function createPortal( + children: ReactNode, + container: Element, + key?: null | string +): ReactPortal; + +export const version: string; +export const render: Renderer; +export const hydrate: Renderer; + +export function unstable_batchedUpdates( + callback: (a: A, b: B) => any, + a: A, + b: B +): void; +export function unstable_batchedUpdates(callback: (a: A) => any, a: A): void; +export function unstable_batchedUpdates(callback: () => any): void; + +export function unstable_renderSubtreeIntoContainer( + parentComponent: Component, + element: DOMElement, T>, + container: Element, + callback?: (element: T) => any +): T; +export function unstable_renderSubtreeIntoContainer< + P, + T extends Component +>( + parentComponent: Component, + element: CElement, + container: Element, + callback?: (component: T) => any +): T; +export function unstable_renderSubtreeIntoContainer

( + parentComponent: Component, + element: ReactElement

, + container: Element, + callback?: (component?: Component | Element) => any +): Component | Element | void; + +export interface Renderer { + // Deprecated(render): The return value is deprecated. + // In future releases the render function's return type will be void. + + ( + element: DOMElement, T>, + container: Element | null, + callback?: () => void + ): T; + + ( + element: Array, any>>, + container: Element | null, + callback?: () => void + ): Element; + + ( + element: SFCElement | Array>, + container: Element | null, + callback?: () => void + ): void; + + >( + element: CElement, + container: Element | null, + callback?: () => void + ): T; + + ( + element: Array>>, + container: Element | null, + callback?: () => void + ): Component; + +

( + element: ReactElement

, + container: Element | null, + callback?: () => void + ): Component | Element | void; + + (element: ReactElement[], container: Element | null, callback?: () => void): + | Component + | Element + | void; +} -- cgit v1.2.3