// Type definitions for React 18.0 // Project: http://facebook.github.io/react/ // Definitions by: Asana // AssureSign // Microsoft // John Reilly // Benoit Benezech // Patricio Zavolinsky // Eric Anderson // Dovydas Navickas // Josh Rutherford // Guilherme Hübner // Ferdy Budhidharma // Johann Rakotoharisoa // Olivier Pascal // Martin Hochel // Frank Li // Jessica Franco // Saransh Kataria // Kanitkorn Sujautra // Sebastian Silbermann // Kyle Scully // Cong Zhang // Dimitri Mitropoulos // JongChan Choi // Victor Magalhães // Dale Tan // Priyanshu Rav // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 // NOTE: Users of the `experimental` builds of React should add a reference // to 'react/experimental' in their project. See experimental.d.ts's top comment // for reference and documentation on how exactly to do it. /// import * as CSS from 'csstype'; import * as PropTypes from 'prop-types'; import { Interaction as SchedulerInteraction } from 'scheduler/tracing'; type NativeAnimationEvent = AnimationEvent; type NativeClipboardEvent = ClipboardEvent; type NativeCompositionEvent = CompositionEvent; type NativeDragEvent = DragEvent; type NativeFocusEvent = FocusEvent; type NativeKeyboardEvent = KeyboardEvent; type NativeMouseEvent = MouseEvent; type NativeTouchEvent = TouchEvent; type NativePointerEvent = PointerEvent; type NativeTransitionEvent = TransitionEvent; type NativeUIEvent = UIEvent; type NativeWheelEvent = WheelEvent; type Booleanish = boolean | 'true' | 'false'; declare const UNDEFINED_VOID_ONLY: unique symbol; // Destructors are only allowed to return void. type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never }; type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never }; // eslint-disable-next-line export-just-namespace export = React; export as namespace React; declare namespace React { // // React Elements // ---------------------------------------------------------------------- type ElementType

= { [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never }[keyof JSX.IntrinsicElements] | ComponentType

; type ComponentType

= ComponentClass

| FunctionComponent

; type JSXElementConstructor

= | ((props: P) => ReactElement | null) | (new (props: P) => Component); interface RefObject { readonly current: T | null; } // Bivariance hack for consistent unsoundness with RefObject type RefCallback = { bivarianceHack(instance: T | null): void }["bivarianceHack"]; type Ref = RefCallback | RefObject | null; type LegacyRef = string | Ref; /** * Gets the instance type for a React element. The instance will be different for various component types: * * - React class components will be the class instance. So if you had `class Foo extends React.Component<{}> {}` * and used `React.ElementRef` then the type would be the instance of `Foo`. * - React stateless functional components do not have a backing instance and so `React.ElementRef` * (when `Bar` is `function Bar() {}`) will give you the `undefined` type. * - JSX intrinsics like `div` will give you their DOM instance. For `React.ElementRef<'div'>` that would be * `HTMLDivElement`. For `React.ElementRef<'input'>` that would be `HTMLInputElement`. * - React stateless functional components that forward a `ref` will give you the `ElementRef` of the forwarded * to component. * * `C` must be the type _of_ a React component so you need to use typeof as in `React.ElementRef`. * * @todo In Flow, this works a little different with forwarded refs and the `AbstractComponent` that * `React.forwardRef()` returns. */ type ElementRef< C extends | ForwardRefExoticComponent | { new (props: any): Component } | ((props: any, context?: any) => ReactElement | null) | keyof JSX.IntrinsicElements > = // need to check first if `ref` is a valid prop for ts@3.0 // otherwise it will infer `{}` instead of `never` "ref" extends keyof ComponentPropsWithRef ? NonNullable["ref"]> extends Ref< infer Instance > ? Instance : never : never; type ComponentState = any; type Key = string | number; /** * @internal You shouldn't need to use this type since you never see these attributes * inside your component or have to validate them. */ interface Attributes { key?: Key | null | undefined; } interface RefAttributes extends Attributes { ref?: Ref | undefined; } interface ClassAttributes extends Attributes { ref?: LegacyRef | undefined; } interface ReactElement

= string | JSXElementConstructor> { type: T; props: P; key: Key | null; } interface ReactComponentElement< T extends keyof JSX.IntrinsicElements | JSXElementConstructor, P = Pick, Exclude, 'key' | 'ref'>> > extends ReactElement> { } interface FunctionComponentElement

extends ReactElement> { ref?: ('ref' extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined; } type CElement> = ComponentElement; interface ComponentElement> extends ReactElement> { ref?: LegacyRef | undefined; } type ClassicElement

= CElement>; // string fallback for custom web-components interface DOMElement

| SVGAttributes, T extends Element> extends ReactElement { ref: LegacyRef; } // ReactHTML for ReactHTMLElement interface ReactHTMLElement extends DetailedReactHTMLElement, T> { } interface DetailedReactHTMLElement

, T extends HTMLElement> extends DOMElement { type: keyof ReactHTML; } // ReactSVG for ReactSVGElement interface ReactSVGElement extends DOMElement, SVGElement> { type: keyof ReactSVG; } interface ReactPortal extends ReactElement { key: Key | null; children: ReactNode; } // // Factories // ---------------------------------------------------------------------- type Factory

= (props?: Attributes & P, ...children: ReactNode[]) => ReactElement

; /** * @deprecated Please use `FunctionComponentFactory` */ type SFCFactory

= FunctionComponentFactory

; type FunctionComponentFactory

= (props?: Attributes & P, ...children: ReactNode[]) => FunctionComponentElement

; type ComponentFactory> = (props?: ClassAttributes & P, ...children: ReactNode[]) => CElement; type CFactory> = ComponentFactory; type ClassicFactory

= CFactory>; type DOMFactory

, T extends Element> = (props?: ClassAttributes & P | null, ...children: ReactNode[]) => DOMElement; interface HTMLFactory extends DetailedHTMLFactory, T> {} interface DetailedHTMLFactory

, T extends HTMLElement> extends DOMFactory { (props?: ClassAttributes & P | null, ...children: ReactNode[]): DetailedReactHTMLElement; } interface SVGFactory extends DOMFactory, SVGElement> { (props?: ClassAttributes & SVGAttributes | null, ...children: ReactNode[]): ReactSVGElement; } /** * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear. */ type ReactText = string | number; /** * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear. */ type ReactChild = ReactElement | string | number; /** * @deprecated Use either `ReactNode[]` if you need an array or `Iterable` if its passed to a host component. */ interface ReactNodeArray extends ReadonlyArray {} type ReactFragment = Iterable; type ReactNode = ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined; // // Top Level API // ---------------------------------------------------------------------- // DOM Elements function createFactory( type: keyof ReactHTML): HTMLFactory; function createFactory( type: keyof ReactSVG): SVGFactory; function createFactory

, T extends Element>( type: string): DOMFactory; // Custom components function createFactory

(type: FunctionComponent

): FunctionComponentFactory

; function createFactory

( type: ClassType, ClassicComponentClass

>): CFactory>; function createFactory, C extends ComponentClass

>( type: ClassType): CFactory; function createFactory

(type: ComponentClass

): Factory

; // DOM Elements // TODO: generalize this to everything in `keyof ReactHTML`, not just "input" function createElement( type: "input", props?: InputHTMLAttributes & ClassAttributes | null, ...children: ReactNode[]): DetailedReactHTMLElement, HTMLInputElement>; function createElement

, T extends HTMLElement>( type: keyof ReactHTML, props?: ClassAttributes & P | null, ...children: ReactNode[]): DetailedReactHTMLElement; function createElement

, T extends SVGElement>( type: keyof ReactSVG, props?: ClassAttributes & P | null, ...children: ReactNode[]): ReactSVGElement; function createElement

, T extends Element>( type: string, props?: ClassAttributes & P | null, ...children: ReactNode[]): DOMElement; // Custom components function createElement

( type: FunctionComponent

, props?: Attributes & P | null, ...children: ReactNode[]): FunctionComponentElement

; function createElement

( type: ClassType, ClassicComponentClass

>, props?: ClassAttributes> & P | null, ...children: ReactNode[]): CElement>; function createElement

, C extends ComponentClass

>( type: ClassType, props?: ClassAttributes & P | null, ...children: ReactNode[]): CElement; function createElement

( type: FunctionComponent

| ComponentClass

| string, props?: Attributes & P | null, ...children: ReactNode[]): ReactElement

; // DOM Elements // ReactHTMLElement function cloneElement

, T extends HTMLElement>( element: DetailedReactHTMLElement, props?: P, ...children: ReactNode[]): DetailedReactHTMLElement; // ReactHTMLElement, less specific function cloneElement

, T extends HTMLElement>( element: ReactHTMLElement, props?: P, ...children: ReactNode[]): ReactHTMLElement; // SVGElement function cloneElement

, T extends SVGElement>( element: ReactSVGElement, props?: P, ...children: ReactNode[]): ReactSVGElement; // DOM Element (has to be the last, because type checking stops at first overload that fits) function cloneElement

, T extends Element>( element: DOMElement, props?: DOMAttributes & P, ...children: ReactNode[]): DOMElement; // Custom components function cloneElement

( element: FunctionComponentElement

, props?: Partial

& Attributes, ...children: ReactNode[]): FunctionComponentElement

; function cloneElement>( element: CElement, props?: Partial

& ClassAttributes, ...children: ReactNode[]): CElement; function cloneElement

( element: ReactElement

, props?: Partial

& Attributes, ...children: ReactNode[]): ReactElement

; // Context via RenderProps interface ProviderProps { value: T; children?: ReactNode | undefined; } interface ConsumerProps { children: (value: T) => ReactNode; } // TODO: similar to how Fragment is actually a symbol, the values returned from createContext, // forwardRef and memo are actually objects that are treated specially by the renderer; see: // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/ReactContext.js#L35-L48 // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/forwardRef.js#L42-L45 // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/memo.js#L27-L31 // However, we have no way of telling the JSX parser that it's a JSX element type or its props other than // by pretending to be a normal component. // // We don't just use ComponentType or FunctionComponent types because you are not supposed to attach statics to this // object, but rather to the original function. interface ExoticComponent

{ /** * **NOTE**: Exotic components are not callable. */ (props: P): (ReactElement|null); readonly $$typeof: symbol; } interface NamedExoticComponent

extends ExoticComponent

{ displayName?: string | undefined; } interface ProviderExoticComponent

extends ExoticComponent

{ propTypes?: WeakValidationMap

| undefined; } type ContextType> = C extends Context ? T : never; // NOTE: only the Context object itself can get a displayName // https://github.com/facebook/react-devtools/blob/e0b854e4c/backend/attachRendererFiber.js#L310-L325 type Provider = ProviderExoticComponent>; type Consumer = ExoticComponent>; interface Context { Provider: Provider; Consumer: Consumer; displayName?: string | undefined; } function createContext( // If you thought this should be optional, see // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106 defaultValue: T, ): Context; function isValidElement

(object: {} | null | undefined): object is ReactElement

; // Sync with `ReactChildren` until `ReactChildren` is removed. const Children: { map(children: C | ReadonlyArray, fn: (child: C, index: number) => T): C extends null | undefined ? C : Array>; forEach(children: C | ReadonlyArray, fn: (child: C, index: number) => void): void; count(children: any): number; only(children: C): C extends any[] ? never : C; toArray(children: ReactNode | ReactNode[]): Array>; }; const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>; const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>; interface SuspenseProps { children?: ReactNode | undefined; /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */ fallback?: ReactNode; } const Suspense: ExoticComponent; const version: string; /** * {@link https://reactjs.org/docs/profiler.html#onrender-callback Profiler API} */ type ProfilerOnRenderCallback = ( id: string, phase: "mount" | "update", actualDuration: number, baseDuration: number, startTime: number, commitTime: number, interactions: Set, ) => void; interface ProfilerProps { children?: ReactNode | undefined; id: string; onRender: ProfilerOnRenderCallback; } const Profiler: ExoticComponent; // // Component API // ---------------------------------------------------------------------- type ReactInstance = Component | Element; // Base component for plain JS classes interface Component

extends ComponentLifecycle { } class Component { // tslint won't let me format the sample code in a way that vscode likes it :( /** * If set, `this.context` will be set at runtime to the current value of the given Context. * * Usage: * * ```ts * type MyContext = number * const Ctx = React.createContext(0) * * class Foo extends React.Component { * static contextType = Ctx * context!: React.ContextType * render () { * return <>My context's value: {this.context}; * } * } * ``` * * @see https://reactjs.org/docs/context.html#classcontexttype */ static contextType?: Context | undefined; /** * If using the new style context, re-declare this in your class to be the * `React.ContextType` of your `static contextType`. * Should be used with type annotation or static contextType. * * ```ts * static contextType = MyContext * // For TS pre-3.7: * context!: React.ContextType * // For TS 3.7 and above: * declare context: React.ContextType * ``` * * @see https://reactjs.org/docs/context.html */ context: unknown; constructor(props: Readonly

| P); /** * @deprecated * @see https://reactjs.org/docs/legacy-context.html */ constructor(props: P, context: any); // We MUST keep setState() as a unified signature because it allows proper checking of the method return type. // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257 // Also, the ` | S` allows intellisense to not be dumbisense setState( state: ((prevState: Readonly, props: Readonly

) => (Pick | S | null)) | (Pick | S | null), callback?: () => void ): void; forceUpdate(callback?: () => void): void; render(): ReactNode; readonly props: Readonly

; state: Readonly; /** * @deprecated * https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs */ refs: { [key: string]: ReactInstance }; } class PureComponent

extends Component { } interface ClassicComponent

extends Component { replaceState(nextState: S, callback?: () => void): void; isMounted(): boolean; getInitialState?(): S; } interface ChildContextProvider { getChildContext(): CC; } // // Class Interfaces // ---------------------------------------------------------------------- type FC

= FunctionComponent

; interface FunctionComponent

{ (props: P, context?: any): ReactElement | null; propTypes?: WeakValidationMap

| undefined; contextTypes?: ValidationMap | undefined; defaultProps?: Partial

| undefined; displayName?: string | undefined; } /** * @deprecated - Equivalent with `React.FC`. */ type VFC

= VoidFunctionComponent

; /** * @deprecated - Equivalent with `React.FunctionComponent`. */ interface VoidFunctionComponent

{ (props: P, context?: any): ReactElement | null; propTypes?: WeakValidationMap

| undefined; contextTypes?: ValidationMap | undefined; defaultProps?: Partial

| undefined; displayName?: string | undefined; } type ForwardedRef = ((instance: T | null) => void) | MutableRefObject | null; interface ForwardRefRenderFunction { (props: P, ref: ForwardedRef): ReactElement | null; displayName?: string | undefined; // explicit rejected with `never` required due to // https://github.com/microsoft/TypeScript/issues/36826 /** * defaultProps are not supported on render functions */ defaultProps?: never | undefined; /** * propTypes are not supported on render functions */ propTypes?: never | undefined; } interface ComponentClass

extends StaticLifecycle { new (props: P, context?: any): Component; propTypes?: WeakValidationMap

| undefined; contextType?: Context | undefined; contextTypes?: ValidationMap | undefined; childContextTypes?: ValidationMap | undefined; defaultProps?: Partial

| undefined; displayName?: string | undefined; } interface ClassicComponentClass

extends ComponentClass

{ new (props: P, context?: any): ClassicComponent; getDefaultProps?(): P; } /** * We use an intersection type to infer multiple type parameters from * a single argument, which is useful for many top-level API defs. * See https://github.com/Microsoft/TypeScript/issues/7234 for more info. */ type ClassType, C extends ComponentClass

> = C & (new (props: P, context?: any) => T); // // Component Specs and Lifecycle // ---------------------------------------------------------------------- // This should actually be something like `Lifecycle | DeprecatedLifecycle`, // as React will _not_ call the deprecated lifecycle methods if any of the new lifecycle // methods are present. interface ComponentLifecycle extends NewLifecycle, DeprecatedLifecycle { /** * Called immediately after a component is mounted. Setting state here will trigger re-rendering. */ componentDidMount?(): void; /** * Called to determine whether the change in props and state should trigger a re-render. * * `Component` always returns true. * `PureComponent` implements a shallow comparison on props and state and returns true if any * props or states have changed. * * If false is returned, `Component#render`, `componentWillUpdate` * and `componentDidUpdate` will not be called. */ shouldComponentUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): boolean; /** * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`. */ componentWillUnmount?(): void; /** * Catches exceptions generated in descendant components. Unhandled exceptions will cause * the entire component tree to unmount. */ componentDidCatch?(error: Error, errorInfo: ErrorInfo): void; } // Unfortunately, we have no way of declaring that the component constructor must implement this interface StaticLifecycle { getDerivedStateFromProps?: GetDerivedStateFromProps | undefined; getDerivedStateFromError?: GetDerivedStateFromError | undefined; } type GetDerivedStateFromProps = /** * Returns an update to a component's state based on its new props and old state. * * Note: its presence prevents any of the deprecated lifecycle methods from being invoked */ (nextProps: Readonly

, prevState: S) => Partial | null; type GetDerivedStateFromError = /** * This lifecycle is invoked after an error has been thrown by a descendant component. * It receives the error that was thrown as a parameter and should return a value to update state. * * Note: its presence prevents any of the deprecated lifecycle methods from being invoked */ (error: any) => Partial | null; // This should be "infer SS" but can't use it yet interface NewLifecycle { /** * Runs before React applies the result of `render` to the document, and * returns an object to be given to componentDidUpdate. Useful for saving * things such as scroll position before `render` causes changes to it. * * Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated * lifecycle events from running. */ getSnapshotBeforeUpdate?(prevProps: Readonly

, prevState: Readonly): SS | null; /** * Called immediately after updating occurs. Not called for the initial render. * * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null. */ componentDidUpdate?(prevProps: Readonly

, prevState: Readonly, snapshot?: SS): void; } interface DeprecatedLifecycle { /** * Called immediately before mounting occurs, and before `Component#render`. * Avoid introducing any side-effects or subscriptions in this method. * * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps * prevents this from being invoked. * * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path */ componentWillMount?(): void; /** * Called immediately before mounting occurs, and before `Component#render`. * Avoid introducing any side-effects or subscriptions in this method. * * This method will not stop working in React 17. * * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps * prevents this from being invoked. * * @deprecated 16.3, use componentDidMount or the constructor instead * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path */ UNSAFE_componentWillMount?(): void; /** * Called when the component may be receiving new props. * React may call this even if props have not changed, so be sure to compare new and existing * props if you only want to handle changes. * * Calling `Component#setState` generally does not trigger this method. * * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps * prevents this from being invoked. * * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path */ componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; /** * Called when the component may be receiving new props. * React may call this even if props have not changed, so be sure to compare new and existing * props if you only want to handle changes. * * Calling `Component#setState` generally does not trigger this method. * * This method will not stop working in React 17. * * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps * prevents this from being invoked. * * @deprecated 16.3, use static getDerivedStateFromProps instead * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path */ UNSAFE_componentWillReceiveProps?(nextProps: Readonly

, nextContext: any): void; /** * Called immediately before rendering when new props or state is received. Not called for the initial render. * * Note: You cannot call `Component#setState` here. * * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps * prevents this from being invoked. * * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path */ componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; /** * Called immediately before rendering when new props or state is received. Not called for the initial render. * * Note: You cannot call `Component#setState` here. * * This method will not stop working in React 17. * * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps * prevents this from being invoked. * * @deprecated 16.3, use getSnapshotBeforeUpdate instead * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path */ UNSAFE_componentWillUpdate?(nextProps: Readonly

, nextState: Readonly, nextContext: any): void; } interface Mixin extends ComponentLifecycle { mixins?: Array> | undefined; statics?: { [key: string]: any; } | undefined; displayName?: string | undefined; propTypes?: ValidationMap | undefined; contextTypes?: ValidationMap | undefined; childContextTypes?: ValidationMap | undefined; getDefaultProps?(): P; getInitialState?(): S; } interface ComponentSpec extends Mixin { render(): ReactNode; [propertyName: string]: any; } function createRef(): RefObject; // will show `ForwardRef(${Component.displayName || Component.name})` in devtools by default, // but can be given its own specific name interface ForwardRefExoticComponent

extends NamedExoticComponent

{ defaultProps?: Partial

| undefined; propTypes?: WeakValidationMap

| undefined; } function forwardRef(render: ForwardRefRenderFunction): ForwardRefExoticComponent & RefAttributes>; /** Ensures that the props do not include ref at all */ type PropsWithoutRef

= // Pick would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions. // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types // https://github.com/Microsoft/TypeScript/issues/28339 P extends any ? ('ref' extends keyof P ? Pick> : P) : P; /** Ensures that the props do not include string ref, which cannot be forwarded */ type PropsWithRef

= // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}. 'ref' extends keyof P ? P extends { ref?: infer R | undefined } ? string extends R ? PropsWithoutRef

& { ref?: Exclude | undefined } : P : P : P; type PropsWithChildren

= P & { children?: ReactNode | undefined }; /** * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded, * or ComponentPropsWithoutRef when refs are not supported. */ type ComponentProps> = T extends JSXElementConstructor ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : {}; type ComponentPropsWithRef = T extends (new (props: infer P) => Component) ? PropsWithoutRef

& RefAttributes> : PropsWithRef>; type ComponentPropsWithoutRef = PropsWithoutRef>; type ComponentRef = T extends NamedExoticComponent< ComponentPropsWithoutRef & RefAttributes > ? Method : ComponentPropsWithRef extends RefAttributes ? Method : never; // will show `Memo(${Component.displayName || Component.name})` in devtools by default, // but can be given its own specific name type MemoExoticComponent> = NamedExoticComponent> & { readonly type: T; }; function memo

( Component: FunctionComponent

, propsAreEqual?: (prevProps: Readonly

, nextProps: Readonly

) => boolean ): NamedExoticComponent

; function memo>( Component: T, propsAreEqual?: (prevProps: Readonly>, nextProps: Readonly>) => boolean ): MemoExoticComponent; type LazyExoticComponent> = ExoticComponent> & { readonly _result: T; }; function lazy>( factory: () => Promise<{ default: T }> ): LazyExoticComponent; // // React Hooks // ---------------------------------------------------------------------- // based on the code in https://github.com/facebook/react/pull/13968 // Unlike the class component setState, the updates are not allowed to be partial type SetStateAction = S | ((prevState: S) => S); // this technically does accept a second argument, but it's already under a deprecation warning // and it's not even released so probably better to not define it. type Dispatch = (value: A) => void; // Since action _can_ be undefined, dispatch may be called without any parameters. type DispatchWithoutAction = () => void; // Unlike redux, the actions _can_ be anything type Reducer = (prevState: S, action: A) => S; // If useReducer accepts a reducer without action, dispatch may be called without any parameters. type ReducerWithoutAction = (prevState: S) => S; // types used to try and prevent the compiler from reducing S // to a supertype common with the second argument to useReducer() type ReducerState> = R extends Reducer ? S : never; type ReducerAction> = R extends Reducer ? A : never; // The identity check is done with the SameValue algorithm (Object.is), which is stricter than === type ReducerStateWithoutAction> = R extends ReducerWithoutAction ? S : never; type DependencyList = ReadonlyArray; // NOTE: callbacks are _only_ allowed to return either void, or a destructor. type EffectCallback = () => (void | Destructor); interface MutableRefObject { current: T; } // This will technically work if you give a Consumer or Provider but it's deprecated and warns /** * Accepts a context object (the value returned from `React.createContext`) and returns the current * context value, as given by the nearest context provider for the given context. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usecontext */ function useContext(context: Context/*, (not public API) observedBits?: number|boolean */): T; /** * Returns a stateful value, and a function to update it. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usestate */ function useState(initialState: S | (() => S)): [S, Dispatch>]; // convenience overload when first argument is omitted /** * Returns a stateful value, and a function to update it. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usestate */ function useState(): [S | undefined, Dispatch>]; /** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */ // overload where dispatch could accept 0 arguments. function useReducer, I>( reducer: R, initializerArg: I, initializer: (arg: I) => ReducerStateWithoutAction ): [ReducerStateWithoutAction, DispatchWithoutAction]; /** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */ // overload where dispatch could accept 0 arguments. function useReducer>( reducer: R, initializerArg: ReducerStateWithoutAction, initializer?: undefined ): [ReducerStateWithoutAction, DispatchWithoutAction]; /** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */ // overload where "I" may be a subset of ReducerState; used to provide autocompletion. // If "I" matches ReducerState exactly then the last overload will allow initializer to be omitted. // the last overload effectively behaves as if the identity function (x => x) is the initializer. function useReducer, I>( reducer: R, initializerArg: I & ReducerState, initializer: (arg: I & ReducerState) => ReducerState ): [ReducerState, Dispatch>]; /** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */ // overload for free "I"; all goes as long as initializer converts it into "ReducerState". function useReducer, I>( reducer: R, initializerArg: I, initializer: (arg: I) => ReducerState ): [ReducerState, Dispatch>]; /** * An alternative to `useState`. * * `useReducer` is usually preferable to `useState` when you have complex state logic that involves * multiple sub-values. It also lets you optimize performance for components that trigger deep * updates because you can pass `dispatch` down instead of callbacks. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usereducer */ // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary. // The Flow types do have an overload for 3-ary invocation with undefined initializer. // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common // supertype between the reducer's return type and the initialState (or the initializer's return type), // which would prevent autocompletion from ever working. // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug // in older versions, or a regression in newer versions of the typescript completion service. function useReducer>( reducer: R, initialState: ReducerState, initializer?: undefined ): [ReducerState, Dispatch>]; /** * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument * (`initialValue`). The returned object will persist for the full lifetime of the component. * * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable * value around similar to how you’d use instance fields in classes. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#useref */ function useRef(initialValue: T): MutableRefObject; // convenience overload for refs given as a ref prop as they typically start with a null value /** * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument * (`initialValue`). The returned object will persist for the full lifetime of the component. * * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable * value around similar to how you’d use instance fields in classes. * * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type * of the generic argument. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#useref */ function useRef(initialValue: T|null): RefObject; // convenience overload for potentially undefined initialValue / call with 0 arguments // has a default to stop it from defaulting to {} instead /** * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument * (`initialValue`). The returned object will persist for the full lifetime of the component. * * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable * value around similar to how you’d use instance fields in classes. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#useref */ function useRef(): MutableRefObject; /** * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations. * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside * `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint. * * Prefer the standard `useEffect` when possible to avoid blocking visual updates. * * If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as * `componentDidMount` and `componentDidUpdate`. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#uselayouteffect */ function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void; /** * Accepts a function that contains imperative, possibly effectful code. * * @param effect Imperative function that can return a cleanup function * @param deps If present, effect will only activate if the values in the list change. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#useeffect */ function useEffect(effect: EffectCallback, deps?: DependencyList): void; // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref /** * `useImperativeHandle` customizes the instance value that is exposed to parent components when using * `ref`. As always, imperative code using refs should be avoided in most cases. * * `useImperativeHandle` should be used with `React.forwardRef`. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#useimperativehandle */ function useImperativeHandle(ref: Ref|undefined, init: () => R, deps?: DependencyList): void; // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key // useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y. /** * `useCallback` will return a memoized version of the callback that only changes if one of the `inputs` * has changed. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usecallback */ // A specific function type would not trigger implicit any. // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types. // tslint:disable-next-line ban-types function useCallback(callback: T, deps: DependencyList): T; /** * `useMemo` will only recompute the memoized value when one of the `deps` has changed. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usememo */ // allow undefined, but don't make it optional as that is very likely a mistake function useMemo(factory: () => T, deps: DependencyList | undefined): T; /** * `useDebugValue` can be used to display a label for custom hooks in React DevTools. * * NOTE: We don’t recommend adding debug values to every custom hook. * It’s most valuable for custom hooks that are part of shared libraries. * * @version 16.8.0 * @see https://reactjs.org/docs/hooks-reference.html#usedebugvalue */ // the name of the custom hook is itself derived from the function name at runtime: // it's just the function name without the "use" prefix. function useDebugValue(value: T, format?: (value: T) => any): void; // must be synchronous export type TransitionFunction = () => VoidOrUndefinedOnly; // strange definition to allow vscode to show documentation on the invocation export interface TransitionStartFunction { /** * State updates caused inside the callback are allowed to be deferred. * * **If some state update causes a component to suspend, that state update should be wrapped in a transition.** * * @param callback A _synchronous_ function which causes state updates that can be deferred. */ (callback: TransitionFunction): void; } /** * Returns a deferred version of the value that may “lag behind” it. * * This is commonly used to keep the interface responsive when you have something that renders immediately * based on user input and something that needs to wait for a data fetch. * * A good example of this is a text input. * * @param value The value that is going to be deferred * * @see https://reactjs.org/docs/concurrent-mode-reference.html#usedeferredvalue */ export function useDeferredValue(value: T): T; /** * Allows components to avoid undesirable loading states by waiting for content to load * before transitioning to the next screen. It also allows components to defer slower, * data fetching updates until subsequent renders so that more crucial updates can be * rendered immediately. * * The `useTransition` hook returns two values in an array. * * The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish. * The second is a function that takes a callback. We can use it to tell React which state we want to defer. * * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**` * * @see https://reactjs.org/docs/concurrent-mode-reference.html#usetransition */ export function useTransition(): [boolean, TransitionStartFunction]; /** * Similar to `useTransition` but allows uses where hooks are not available. * * @param callback A _synchronous_ function which causes state updates that can be deferred. */ export function startTransition(scope: TransitionFunction): void; export function useId(): string; /** * @param effect Imperative function that can return a cleanup function * @param deps If present, effect will only activate if the values in the list change. * * @see https://github.com/facebook/react/pull/21913 */ export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void; /** * @param subscribe * @param getSnapshot * * @see https://github.com/reactwg/react-18/discussions/86 */ // keep in sync with `useSyncExternalStore` from `use-sync-external-store` export function useSyncExternalStore( subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, ): Snapshot; // // Event System // ---------------------------------------------------------------------- // TODO: change any to unknown when moving to TS v3 interface BaseSyntheticEvent { nativeEvent: E; currentTarget: C; target: T; bubbles: boolean; cancelable: boolean; defaultPrevented: boolean; eventPhase: number; isTrusted: boolean; preventDefault(): void; isDefaultPrevented(): boolean; stopPropagation(): void; isPropagationStopped(): boolean; persist(): void; timeStamp: number; type: string; } /** * currentTarget - a reference to the element on which the event listener is registered. * * target - a reference to the element from which the event was originally dispatched. * This might be a child element to the element on which the event listener is registered. * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682 */ interface SyntheticEvent extends BaseSyntheticEvent {} interface ClipboardEvent extends SyntheticEvent { clipboardData: DataTransfer; } interface CompositionEvent extends SyntheticEvent { data: string; } interface DragEvent extends MouseEvent { dataTransfer: DataTransfer; } interface PointerEvent extends MouseEvent { pointerId: number; pressure: number; tangentialPressure: number; tiltX: number; tiltY: number; twist: number; width: number; height: number; pointerType: 'mouse' | 'pen' | 'touch'; isPrimary: boolean; } interface FocusEvent extends SyntheticEvent { relatedTarget: (EventTarget & RelatedTarget) | null; target: EventTarget & Target; } interface FormEvent extends SyntheticEvent { } interface InvalidEvent extends SyntheticEvent { target: EventTarget & T; } interface ChangeEvent extends SyntheticEvent { target: EventTarget & T; } interface KeyboardEvent extends UIEvent { altKey: boolean; /** @deprecated */ charCode: number; ctrlKey: boolean; code: string; /** * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. */ getModifierState(key: string): boolean; /** * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values */ key: string; /** @deprecated */ keyCode: number; locale: string; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; /** @deprecated */ which: number; } interface MouseEvent extends UIEvent { altKey: boolean; button: number; buttons: number; clientX: number; clientY: number; ctrlKey: boolean; /** * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. */ getModifierState(key: string): boolean; metaKey: boolean; movementX: number; movementY: number; pageX: number; pageY: number; relatedTarget: EventTarget | null; screenX: number; screenY: number; shiftKey: boolean; } interface TouchEvent extends UIEvent { altKey: boolean; changedTouches: TouchList; ctrlKey: boolean; /** * See [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#keys-modifier). for a list of valid (case-sensitive) arguments to this method. */ getModifierState(key: string): boolean; metaKey: boolean; shiftKey: boolean; targetTouches: TouchList; touches: TouchList; } interface UIEvent extends SyntheticEvent { detail: number; view: AbstractView; } interface WheelEvent extends MouseEvent { deltaMode: number; deltaX: number; deltaY: number; deltaZ: number; } interface AnimationEvent extends SyntheticEvent { animationName: string; elapsedTime: number; pseudoElement: string; } interface TransitionEvent extends SyntheticEvent { elapsedTime: number; propertyName: string; pseudoElement: string; } // // Event Handler Types // ---------------------------------------------------------------------- type EventHandler> = { bivarianceHack(event: E): void }["bivarianceHack"]; type ReactEventHandler = EventHandler>; type ClipboardEventHandler = EventHandler>; type CompositionEventHandler = EventHandler>; type DragEventHandler = EventHandler>; type FocusEventHandler = EventHandler>; type FormEventHandler = EventHandler>; type ChangeEventHandler = EventHandler>; type KeyboardEventHandler = EventHandler>; type MouseEventHandler = EventHandler>; type TouchEventHandler = EventHandler>; type PointerEventHandler = EventHandler>; type UIEventHandler = EventHandler>; type WheelEventHandler = EventHandler>; type AnimationEventHandler = EventHandler>; type TransitionEventHandler = EventHandler>; // // Props / DOM Attributes // ---------------------------------------------------------------------- interface HTMLProps extends AllHTMLAttributes, ClassAttributes { } type DetailedHTMLProps, T> = ClassAttributes & E; interface SVGProps extends SVGAttributes, ClassAttributes { } interface DOMAttributes { children?: ReactNode | undefined; dangerouslySetInnerHTML?: { __html: string; } | undefined; // Clipboard Events onCopy?: ClipboardEventHandler | undefined; onCopyCapture?: ClipboardEventHandler | undefined; onCut?: ClipboardEventHandler | undefined; onCutCapture?: ClipboardEventHandler | undefined; onPaste?: ClipboardEventHandler | undefined; onPasteCapture?: ClipboardEventHandler | undefined; // Composition Events onCompositionEnd?: CompositionEventHandler | undefined; onCompositionEndCapture?: CompositionEventHandler | undefined; onCompositionStart?: CompositionEventHandler | undefined; onCompositionStartCapture?: CompositionEventHandler | undefined; onCompositionUpdate?: CompositionEventHandler | undefined; onCompositionUpdateCapture?: CompositionEventHandler | undefined; // Focus Events onFocus?: FocusEventHandler | undefined; onFocusCapture?: FocusEventHandler | undefined; onBlur?: FocusEventHandler | undefined; onBlurCapture?: FocusEventHandler | undefined; // Form Events onChange?: FormEventHandler | undefined; onChangeCapture?: FormEventHandler | undefined; onBeforeInput?: FormEventHandler | undefined; onBeforeInputCapture?: FormEventHandler | undefined; onInput?: FormEventHandler | undefined; onInputCapture?: FormEventHandler | undefined; onReset?: FormEventHandler | undefined; onResetCapture?: FormEventHandler | undefined; onSubmit?: FormEventHandler | undefined; onSubmitCapture?: FormEventHandler | undefined; onInvalid?: FormEventHandler | undefined; onInvalidCapture?: FormEventHandler | undefined; // Image Events onLoad?: ReactEventHandler | undefined; onLoadCapture?: ReactEventHandler | undefined; onError?: ReactEventHandler | undefined; // also a Media Event onErrorCapture?: ReactEventHandler | undefined; // also a Media Event // Keyboard Events onKeyDown?: KeyboardEventHandler | undefined; onKeyDownCapture?: KeyboardEventHandler | undefined; /** @deprecated */ onKeyPress?: KeyboardEventHandler | undefined; /** @deprecated */ onKeyPressCapture?: KeyboardEventHandler | undefined; onKeyUp?: KeyboardEventHandler | undefined; onKeyUpCapture?: KeyboardEventHandler | undefined; // Media Events onAbort?: ReactEventHandler | undefined; onAbortCapture?: ReactEventHandler | undefined; onCanPlay?: ReactEventHandler | undefined; onCanPlayCapture?: ReactEventHandler | undefined; onCanPlayThrough?: ReactEventHandler | undefined; onCanPlayThroughCapture?: ReactEventHandler | undefined; onDurationChange?: ReactEventHandler | undefined; onDurationChangeCapture?: ReactEventHandler | undefined; onEmptied?: ReactEventHandler | undefined; onEmptiedCapture?: ReactEventHandler | undefined; onEncrypted?: ReactEventHandler | undefined; onEncryptedCapture?: ReactEventHandler | undefined; onEnded?: ReactEventHandler | undefined; onEndedCapture?: ReactEventHandler | undefined; onLoadedData?: ReactEventHandler | undefined; onLoadedDataCapture?: ReactEventHandler | undefined; onLoadedMetadata?: ReactEventHandler | undefined; onLoadedMetadataCapture?: ReactEventHandler | undefined; onLoadStart?: ReactEventHandler | undefined; onLoadStartCapture?: ReactEventHandler | undefined; onPause?: ReactEventHandler | undefined; onPauseCapture?: ReactEventHandler | undefined; onPlay?: ReactEventHandler | undefined; onPlayCapture?: ReactEventHandler | undefined; onPlaying?: ReactEventHandler | undefined; onPlayingCapture?: ReactEventHandler | undefined; onProgress?: ReactEventHandler | undefined; onProgressCapture?: ReactEventHandler | undefined; onRateChange?: ReactEventHandler | undefined; onRateChangeCapture?: ReactEventHandler | undefined; onSeeked?: ReactEventHandler | undefined; onSeekedCapture?: ReactEventHandler | undefined; onSeeking?: ReactEventHandler | undefined; onSeekingCapture?: ReactEventHandler | undefined; onStalled?: ReactEventHandler | undefined; onStalledCapture?: ReactEventHandler | undefined; onSuspend?: ReactEventHandler | undefined; onSuspendCapture?: ReactEventHandler | undefined; onTimeUpdate?: ReactEventHandler | undefined; onTimeUpdateCapture?: ReactEventHandler | undefined; onVolumeChange?: ReactEventHandler | undefined; onVolumeChangeCapture?: ReactEventHandler | undefined; onWaiting?: ReactEventHandler | undefined; onWaitingCapture?: ReactEventHandler | undefined; // MouseEvents onAuxClick?: MouseEventHandler | undefined; onAuxClickCapture?: MouseEventHandler | undefined; onClick?: MouseEventHandler | undefined; onClickCapture?: MouseEventHandler | undefined; onContextMenu?: MouseEventHandler | undefined; onContextMenuCapture?: MouseEventHandler | undefined; onDoubleClick?: MouseEventHandler | undefined; onDoubleClickCapture?: MouseEventHandler | undefined; onDrag?: DragEventHandler | undefined; onDragCapture?: DragEventHandler | undefined; onDragEnd?: DragEventHandler | undefined; onDragEndCapture?: DragEventHandler | undefined; onDragEnter?: DragEventHandler | undefined; onDragEnterCapture?: DragEventHandler | undefined; onDragExit?: DragEventHandler | undefined; onDragExitCapture?: DragEventHandler | undefined; onDragLeave?: DragEventHandler | undefined; onDragLeaveCapture?: DragEventHandler | undefined; onDragOver?: DragEventHandler | undefined; onDragOverCapture?: DragEventHandler | undefined; onDragStart?: DragEventHandler | undefined; onDragStartCapture?: DragEventHandler | undefined; onDrop?: DragEventHandler | undefined; onDropCapture?: DragEventHandler | undefined; onMouseDown?: MouseEventHandler | undefined; onMouseDownCapture?: MouseEventHandler | undefined; onMouseEnter?: MouseEventHandler | undefined; onMouseLeave?: MouseEventHandler | undefined; onMouseMove?: MouseEventHandler | undefined; onMouseMoveCapture?: MouseEventHandler | undefined; onMouseOut?: MouseEventHandler | undefined; onMouseOutCapture?: MouseEventHandler | undefined; onMouseOver?: MouseEventHandler | undefined; onMouseOverCapture?: MouseEventHandler | undefined; onMouseUp?: MouseEventHandler | undefined; onMouseUpCapture?: MouseEventHandler | undefined; // Selection Events onSelect?: ReactEventHandler | undefined; onSelectCapture?: ReactEventHandler | undefined; // Touch Events onTouchCancel?: TouchEventHandler | undefined; onTouchCancelCapture?: TouchEventHandler | undefined; onTouchEnd?: TouchEventHandler | undefined; onTouchEndCapture?: TouchEventHandler | undefined; onTouchMove?: TouchEventHandler | undefined; onTouchMoveCapture?: TouchEventHandler | undefined; onTouchStart?: TouchEventHandler | undefined; onTouchStartCapture?: TouchEventHandler | undefined; // Pointer Events onPointerDown?: PointerEventHandler | undefined; onPointerDownCapture?: PointerEventHandler | undefined; onPointerMove?: PointerEventHandler | undefined; onPointerMoveCapture?: PointerEventHandler | undefined; onPointerUp?: PointerEventHandler | undefined; onPointerUpCapture?: PointerEventHandler | undefined; onPointerCancel?: PointerEventHandler | undefined; onPointerCancelCapture?: PointerEventHandler | undefined; onPointerEnter?: PointerEventHandler | undefined; onPointerEnterCapture?: PointerEventHandler | undefined; onPointerLeave?: PointerEventHandler | undefined; onPointerLeaveCapture?: PointerEventHandler | undefined; onPointerOver?: PointerEventHandler | undefined; onPointerOverCapture?: PointerEventHandler | undefined; onPointerOut?: PointerEventHandler | undefined; onPointerOutCapture?: PointerEventHandler | undefined; onGotPointerCapture?: PointerEventHandler | undefined; onGotPointerCaptureCapture?: PointerEventHandler | undefined; onLostPointerCapture?: PointerEventHandler | undefined; onLostPointerCaptureCapture?: PointerEventHandler | undefined; // UI Events onScroll?: UIEventHandler | undefined; onScrollCapture?: UIEventHandler | undefined; // Wheel Events onWheel?: WheelEventHandler | undefined; onWheelCapture?: WheelEventHandler | undefined; // Animation Events onAnimationStart?: AnimationEventHandler | undefined; onAnimationStartCapture?: AnimationEventHandler | undefined; onAnimationEnd?: AnimationEventHandler | undefined; onAnimationEndCapture?: AnimationEventHandler | undefined; onAnimationIteration?: AnimationEventHandler | undefined; onAnimationIterationCapture?: AnimationEventHandler | undefined; // Transition Events onTransitionEnd?: TransitionEventHandler | undefined; onTransitionEndCapture?: TransitionEventHandler | undefined; } export interface CSSProperties extends CSS.Properties { /** * The index signature was removed to enable closed typing for style * using CSSType. You're able to use type assertion or module augmentation * to add properties or an index signature of your own. * * For examples and more information, visit: * https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors */ } // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/ interface AriaAttributes { /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */ 'aria-activedescendant'?: string | undefined; /** Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute. */ 'aria-atomic'?: Booleanish | undefined; /** * Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be * presented if they are made. */ 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both' | undefined; /** Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user. */ 'aria-busy'?: Booleanish | undefined; /** * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets. * @see aria-pressed @see aria-selected. */ 'aria-checked'?: boolean | 'false' | 'mixed' | 'true' | undefined; /** * Defines the total number of columns in a table, grid, or treegrid. * @see aria-colindex. */ 'aria-colcount'?: number | undefined; /** * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid. * @see aria-colcount @see aria-colspan. */ 'aria-colindex'?: number | undefined; /** * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid. * @see aria-colindex @see aria-rowspan. */ 'aria-colspan'?: number | undefined; /** * Identifies the element (or elements) whose contents or presence are controlled by the current element. * @see aria-owns. */ 'aria-controls'?: string | undefined; /** Indicates the element that represents the current item within a container or set of related elements. */ 'aria-current'?: boolean | 'false' | 'true' | 'page' | 'step' | 'location' | 'date' | 'time' | undefined; /** * Identifies the element (or elements) that describes the object. * @see aria-labelledby */ 'aria-describedby'?: string | undefined; /** * Identifies the element that provides a detailed, extended description for the object. * @see aria-describedby. */ 'aria-details'?: string | undefined; /** * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable. * @see aria-hidden @see aria-readonly. */ 'aria-disabled'?: Booleanish | undefined; /** * Indicates what functions can be performed when a dragged object is released on the drop target. * @deprecated in ARIA 1.1 */ 'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined; /** * Identifies the element that provides an error message for the object. * @see aria-invalid @see aria-describedby. */ 'aria-errormessage'?: string | undefined; /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */ 'aria-expanded'?: Booleanish | undefined; /** * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion, * allows assistive technology to override the general default of reading in document source order. */ 'aria-flowto'?: string | undefined; /** * Indicates an element's "grabbed" state in a drag-and-drop operation. * @deprecated in ARIA 1.1 */ 'aria-grabbed'?: Booleanish | undefined; /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */ 'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | undefined; /** * Indicates whether the element is exposed to an accessibility API. * @see aria-disabled. */ 'aria-hidden'?: Booleanish | undefined; /** * Indicates the entered value does not conform to the format expected by the application. * @see aria-errormessage. */ 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling' | undefined; /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */ 'aria-keyshortcuts'?: string | undefined; /** * Defines a string value that labels the current element. * @see aria-labelledby. */ 'aria-label'?: string | undefined; /** * Identifies the element (or elements) that labels the current element. * @see aria-describedby. */ 'aria-labelledby'?: string | undefined; /** Defines the hierarchical level of an element within a structure. */ 'aria-level'?: number | undefined; /** Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */ 'aria-live'?: 'off' | 'assertive' | 'polite' | undefined; /** Indicates whether an element is modal when displayed. */ 'aria-modal'?: Booleanish | undefined; /** Indicates whether a text box accepts multiple lines of input or only a single line. */ 'aria-multiline'?: Booleanish | undefined; /** Indicates that the user may select more than one item from the current selectable descendants. */ 'aria-multiselectable'?: Booleanish | undefined; /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */ 'aria-orientation'?: 'horizontal' | 'vertical' | undefined; /** * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship * between DOM elements where the DOM hierarchy cannot be used to represent the relationship. * @see aria-controls. */ 'aria-owns'?: string | undefined; /** * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value. * A hint could be a sample value or a brief description of the expected format. */ 'aria-placeholder'?: string | undefined; /** * Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. * @see aria-setsize. */ 'aria-posinset'?: number | undefined; /** * Indicates the current "pressed" state of toggle buttons. * @see aria-checked @see aria-selected. */ 'aria-pressed'?: boolean | 'false' | 'mixed' | 'true' | undefined; /** * Indicates that the element is not editable, but is otherwise operable. * @see aria-disabled. */ 'aria-readonly'?: Booleanish | undefined; /** * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified. * @see aria-atomic. */ 'aria-relevant'?: 'additions' | 'additions removals' | 'additions text' | 'all' | 'removals' | 'removals additions' | 'removals text' | 'text' | 'text additions' | 'text removals' | undefined; /** Indicates that user input is required on the element before a form may be submitted. */ 'aria-required'?: Booleanish | undefined; /** Defines a human-readable, author-localized description for the role of an element. */ 'aria-roledescription'?: string | undefined; /** * Defines the total number of rows in a table, grid, or treegrid. * @see aria-rowindex. */ 'aria-rowcount'?: number | undefined; /** * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid. * @see aria-rowcount @see aria-rowspan. */ 'aria-rowindex'?: number | undefined; /** * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid. * @see aria-rowindex @see aria-colspan. */ 'aria-rowspan'?: number | undefined; /** * Indicates the current "selected" state of various widgets. * @see aria-checked @see aria-pressed. */ 'aria-selected'?: Booleanish | undefined; /** * Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM. * @see aria-posinset. */ 'aria-setsize'?: number | undefined; /** Indicates if items in a table or grid are sorted in ascending or descending order. */ 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other' | undefined; /** Defines the maximum allowed value for a range widget. */ 'aria-valuemax'?: number | undefined; /** Defines the minimum allowed value for a range widget. */ 'aria-valuemin'?: number | undefined; /** * Defines the current value for a range widget. * @see aria-valuetext. */ 'aria-valuenow'?: number | undefined; /** Defines the human readable text alternative of aria-valuenow for a range widget. */ 'aria-valuetext'?: string | undefined; } // All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions type AriaRole = | 'alert' | 'alertdialog' | 'application' | 'article' | 'banner' | 'button' | 'cell' | 'checkbox' | 'columnheader' | 'combobox' | 'complementary' | 'contentinfo' | 'definition' | 'dialog' | 'directory' | 'document' | 'feed' | 'figure' | 'form' | 'grid' | 'gridcell' | 'group' | 'heading' | 'img' | 'link' | 'list' | 'listbox' | 'listitem' | 'log' | 'main' | 'marquee' | 'math' | 'menu' | 'menubar' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'navigation' | 'none' | 'note' | 'option' | 'presentation' | 'progressbar' | 'radio' | 'radiogroup' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'scrollbar' | 'search' | 'searchbox' | 'separator' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'table' | 'tablist' | 'tabpanel' | 'term' | 'textbox' | 'timer' | 'toolbar' | 'tooltip' | 'tree' | 'treegrid' | 'treeitem' | (string & {}); interface HTMLAttributes extends AriaAttributes, DOMAttributes { // React-specific Attributes defaultChecked?: boolean | undefined; defaultValue?: string | number | ReadonlyArray | undefined; suppressContentEditableWarning?: boolean | undefined; suppressHydrationWarning?: boolean | undefined; // Standard HTML Attributes accessKey?: string | undefined; className?: string | undefined; contentEditable?: Booleanish | "inherit" | undefined; contextMenu?: string | undefined; dir?: string | undefined; draggable?: Booleanish | undefined; hidden?: boolean | undefined; id?: string | undefined; lang?: string | undefined; placeholder?: string | undefined; slot?: string | undefined; spellCheck?: Booleanish | undefined; style?: CSSProperties | undefined; tabIndex?: number | undefined; title?: string | undefined; translate?: 'yes' | 'no' | undefined; // Unknown radioGroup?: string | undefined; // , // WAI-ARIA role?: AriaRole | undefined; // RDFa Attributes about?: string | undefined; datatype?: string | undefined; inlist?: any; prefix?: string | undefined; property?: string | undefined; resource?: string | undefined; typeof?: string | undefined; vocab?: string | undefined; // Non-standard Attributes autoCapitalize?: string | undefined; autoCorrect?: string | undefined; autoSave?: string | undefined; color?: string | undefined; itemProp?: string | undefined; itemScope?: boolean | undefined; itemType?: string | undefined; itemID?: string | undefined; itemRef?: string | undefined; results?: number | undefined; security?: string | undefined; unselectable?: 'on' | 'off' | undefined; // Living Standard /** * Hints at the type of data that might be entered by the user while editing the element or its contents * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute */ inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search' | undefined; /** * Specify that a standard HTML element should behave like a defined custom built-in element * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is */ is?: string | undefined; } interface AllHTMLAttributes extends HTMLAttributes { // Standard HTML Attributes accept?: string | undefined; acceptCharset?: string | undefined; action?: string | undefined; allowFullScreen?: boolean | undefined; allowTransparency?: boolean | undefined; alt?: string | undefined; as?: string | undefined; async?: boolean | undefined; autoComplete?: string | undefined; autoFocus?: boolean | undefined; autoPlay?: boolean | undefined; capture?: boolean | 'user' | 'environment' | undefined; cellPadding?: number | string | undefined; cellSpacing?: number | string | undefined; charSet?: string | undefined; challenge?: string | undefined; checked?: boolean | undefined; cite?: string | undefined; classID?: string | undefined; cols?: number | undefined; colSpan?: number | undefined; content?: string | undefined; controls?: boolean | undefined; coords?: string | undefined; crossOrigin?: string | undefined; data?: string | undefined; dateTime?: string | undefined; default?: boolean | undefined; defer?: boolean | undefined; disabled?: boolean | undefined; download?: any; encType?: string | undefined; form?: string | undefined; formAction?: string | undefined; formEncType?: string | undefined; formMethod?: string | undefined; formNoValidate?: boolean | undefined; formTarget?: string | undefined; frameBorder?: number | string | undefined; headers?: string | undefined; height?: number | string | undefined; high?: number | undefined; href?: string | undefined; hrefLang?: string | undefined; htmlFor?: string | undefined; httpEquiv?: string | undefined; integrity?: string | undefined; keyParams?: string | undefined; keyType?: string | undefined; kind?: string | undefined; label?: string | undefined; list?: string | undefined; loop?: boolean | undefined; low?: number | undefined; manifest?: string | undefined; marginHeight?: number | undefined; marginWidth?: number | undefined; max?: number | string | undefined; maxLength?: number | undefined; media?: string | undefined; mediaGroup?: string | undefined; method?: string | undefined; min?: number | string | undefined; minLength?: number | undefined; multiple?: boolean | undefined; muted?: boolean | undefined; name?: string | undefined; nonce?: string | undefined; noValidate?: boolean | undefined; open?: boolean | undefined; optimum?: number | undefined; pattern?: string | undefined; placeholder?: string | undefined; playsInline?: boolean | undefined; poster?: string | undefined; preload?: string | undefined; readOnly?: boolean | undefined; rel?: string | undefined; required?: boolean | undefined; reversed?: boolean | undefined; rows?: number | undefined; rowSpan?: number | undefined; sandbox?: string | undefined; scope?: string | undefined; scoped?: boolean | undefined; scrolling?: string | undefined; seamless?: boolean | undefined; selected?: boolean | undefined; shape?: string | undefined; size?: number | undefined; sizes?: string | undefined; span?: number | undefined; src?: string | undefined; srcDoc?: string | undefined; srcLang?: string | undefined; srcSet?: string | undefined; start?: number | undefined; step?: number | string | undefined; summary?: string | undefined; target?: string | undefined; type?: string | undefined; useMap?: string | undefined; value?: string | ReadonlyArray | number | undefined; width?: number | string | undefined; wmode?: string | undefined; wrap?: string | undefined; } type HTMLAttributeReferrerPolicy = | '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'; type HTMLAttributeAnchorTarget = | '_self' | '_blank' | '_parent' | '_top' | (string & {}); interface AnchorHTMLAttributes extends HTMLAttributes { download?: any; href?: string | undefined; hrefLang?: string | undefined; media?: string | undefined; ping?: string | undefined; rel?: string | undefined; target?: HTMLAttributeAnchorTarget | undefined; type?: string | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; } interface AudioHTMLAttributes extends MediaHTMLAttributes {} interface AreaHTMLAttributes extends HTMLAttributes { alt?: string | undefined; coords?: string | undefined; download?: any; href?: string | undefined; hrefLang?: string | undefined; media?: string | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; rel?: string | undefined; shape?: string | undefined; target?: string | undefined; } interface BaseHTMLAttributes extends HTMLAttributes { href?: string | undefined; target?: string | undefined; } interface BlockquoteHTMLAttributes extends HTMLAttributes { cite?: string | undefined; } interface ButtonHTMLAttributes extends HTMLAttributes { autoFocus?: boolean | undefined; disabled?: boolean | undefined; form?: string | undefined; formAction?: string | undefined; formEncType?: string | undefined; formMethod?: string | undefined; formNoValidate?: boolean | undefined; formTarget?: string | undefined; name?: string | undefined; type?: 'submit' | 'reset' | 'button' | undefined; value?: string | ReadonlyArray | number | undefined; } interface CanvasHTMLAttributes extends HTMLAttributes { height?: number | string | undefined; width?: number | string | undefined; } interface ColHTMLAttributes extends HTMLAttributes { span?: number | undefined; width?: number | string | undefined; } interface ColgroupHTMLAttributes extends HTMLAttributes { span?: number | undefined; } interface DataHTMLAttributes extends HTMLAttributes { value?: string | ReadonlyArray | number | undefined; } interface DetailsHTMLAttributes extends HTMLAttributes { open?: boolean | undefined; onToggle?: ReactEventHandler | undefined; } interface DelHTMLAttributes extends HTMLAttributes { cite?: string | undefined; dateTime?: string | undefined; } interface DialogHTMLAttributes extends HTMLAttributes { onCancel?: ReactEventHandler | undefined; onClose?: ReactEventHandler | undefined; open?: boolean | undefined; } interface EmbedHTMLAttributes extends HTMLAttributes { height?: number | string | undefined; src?: string | undefined; type?: string | undefined; width?: number | string | undefined; } interface FieldsetHTMLAttributes extends HTMLAttributes { disabled?: boolean | undefined; form?: string | undefined; name?: string | undefined; } interface FormHTMLAttributes extends HTMLAttributes { acceptCharset?: string | undefined; action?: string | undefined; autoComplete?: string | undefined; encType?: string | undefined; method?: string | undefined; name?: string | undefined; noValidate?: boolean | undefined; target?: string | undefined; rel?: string | undefined; } interface HtmlHTMLAttributes extends HTMLAttributes { manifest?: string | undefined; } interface IframeHTMLAttributes extends HTMLAttributes { allow?: string | undefined; allowFullScreen?: boolean | undefined; allowTransparency?: boolean | undefined; /** @deprecated */ frameBorder?: number | string | undefined; height?: number | string | undefined; loading?: "eager" | "lazy" | undefined; /** @deprecated */ marginHeight?: number | undefined; /** @deprecated */ marginWidth?: number | undefined; name?: string | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; sandbox?: string | undefined; /** @deprecated */ scrolling?: string | undefined; seamless?: boolean | undefined; src?: string | undefined; srcDoc?: string | undefined; width?: number | string | undefined; } interface ImgHTMLAttributes extends HTMLAttributes { alt?: string | undefined; crossOrigin?: "anonymous" | "use-credentials" | "" | undefined; decoding?: "async" | "auto" | "sync" | undefined; height?: number | string | undefined; loading?: "eager" | "lazy" | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; sizes?: string | undefined; src?: string | undefined; srcSet?: string | undefined; useMap?: string | undefined; width?: number | string | undefined; } interface InsHTMLAttributes extends HTMLAttributes { cite?: string | undefined; dateTime?: string | undefined; } type HTMLInputTypeAttribute = | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' | (string & {}); interface InputHTMLAttributes extends HTMLAttributes { accept?: string | undefined; alt?: string | undefined; autoComplete?: string | undefined; autoFocus?: boolean | undefined; capture?: boolean | 'user' | 'environment' | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute checked?: boolean | undefined; crossOrigin?: string | undefined; disabled?: boolean | undefined; enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined; form?: string | undefined; formAction?: string | undefined; formEncType?: string | undefined; formMethod?: string | undefined; formNoValidate?: boolean | undefined; formTarget?: string | undefined; height?: number | string | undefined; list?: string | undefined; max?: number | string | undefined; maxLength?: number | undefined; min?: number | string | undefined; minLength?: number | undefined; multiple?: boolean | undefined; name?: string | undefined; pattern?: string | undefined; placeholder?: string | undefined; readOnly?: boolean | undefined; required?: boolean | undefined; size?: number | undefined; src?: string | undefined; step?: number | string | undefined; type?: HTMLInputTypeAttribute | undefined; value?: string | ReadonlyArray | number | undefined; width?: number | string | undefined; onChange?: ChangeEventHandler | undefined; } interface KeygenHTMLAttributes extends HTMLAttributes { autoFocus?: boolean | undefined; challenge?: string | undefined; disabled?: boolean | undefined; form?: string | undefined; keyType?: string | undefined; keyParams?: string | undefined; name?: string | undefined; } interface LabelHTMLAttributes extends HTMLAttributes { form?: string | undefined; htmlFor?: string | undefined; } interface LiHTMLAttributes extends HTMLAttributes { value?: string | ReadonlyArray | number | undefined; } interface LinkHTMLAttributes extends HTMLAttributes { as?: string | undefined; crossOrigin?: string | undefined; href?: string | undefined; hrefLang?: string | undefined; integrity?: string | undefined; media?: string | undefined; imageSrcSet?: string | undefined; imageSizes?: string | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; rel?: string | undefined; sizes?: string | undefined; type?: string | undefined; charSet?: string | undefined; } interface MapHTMLAttributes extends HTMLAttributes { name?: string | undefined; } interface MenuHTMLAttributes extends HTMLAttributes { type?: string | undefined; } interface MediaHTMLAttributes extends HTMLAttributes { autoPlay?: boolean | undefined; controls?: boolean | undefined; controlsList?: string | undefined; crossOrigin?: string | undefined; loop?: boolean | undefined; mediaGroup?: string | undefined; muted?: boolean | undefined; playsInline?: boolean | undefined; preload?: string | undefined; src?: string | undefined; } interface MetaHTMLAttributes extends HTMLAttributes { charSet?: string | undefined; content?: string | undefined; httpEquiv?: string | undefined; name?: string | undefined; media?: string | undefined; } interface MeterHTMLAttributes extends HTMLAttributes { form?: string | undefined; high?: number | undefined; low?: number | undefined; max?: number | string | undefined; min?: number | string | undefined; optimum?: number | undefined; value?: string | ReadonlyArray | number | undefined; } interface QuoteHTMLAttributes extends HTMLAttributes { cite?: string | undefined; } interface ObjectHTMLAttributes extends HTMLAttributes { classID?: string | undefined; data?: string | undefined; form?: string | undefined; height?: number | string | undefined; name?: string | undefined; type?: string | undefined; useMap?: string | undefined; width?: number | string | undefined; wmode?: string | undefined; } interface OlHTMLAttributes extends HTMLAttributes { reversed?: boolean | undefined; start?: number | undefined; type?: '1' | 'a' | 'A' | 'i' | 'I' | undefined; } interface OptgroupHTMLAttributes extends HTMLAttributes { disabled?: boolean | undefined; label?: string | undefined; } interface OptionHTMLAttributes extends HTMLAttributes { disabled?: boolean | undefined; label?: string | undefined; selected?: boolean | undefined; value?: string | ReadonlyArray | number | undefined; } interface OutputHTMLAttributes extends HTMLAttributes { form?: string | undefined; htmlFor?: string | undefined; name?: string | undefined; } interface ParamHTMLAttributes extends HTMLAttributes { name?: string | undefined; value?: string | ReadonlyArray | number | undefined; } interface ProgressHTMLAttributes extends HTMLAttributes { max?: number | string | undefined; value?: string | ReadonlyArray | number | undefined; } interface SlotHTMLAttributes extends HTMLAttributes { name?: string | undefined; } interface ScriptHTMLAttributes extends HTMLAttributes { async?: boolean | undefined; /** @deprecated */ charSet?: string | undefined; crossOrigin?: string | undefined; defer?: boolean | undefined; integrity?: string | undefined; noModule?: boolean | undefined; nonce?: string | undefined; referrerPolicy?: HTMLAttributeReferrerPolicy | undefined; src?: string | undefined; type?: string | undefined; } interface SelectHTMLAttributes extends HTMLAttributes { autoComplete?: string | undefined; autoFocus?: boolean | undefined; disabled?: boolean | undefined; form?: string | undefined; multiple?: boolean | undefined; name?: string | undefined; required?: boolean | undefined; size?: number | undefined; value?: string | ReadonlyArray | number | undefined; onChange?: ChangeEventHandler | undefined; } interface SourceHTMLAttributes extends HTMLAttributes { height?: number | string | undefined; media?: string | undefined; sizes?: string | undefined; src?: string | undefined; srcSet?: string | undefined; type?: string | undefined; width?: number | string | undefined; } interface StyleHTMLAttributes extends HTMLAttributes { media?: string | undefined; nonce?: string | undefined; scoped?: boolean | undefined; type?: string | undefined; } interface TableHTMLAttributes extends HTMLAttributes { align?: "left" | "center" | "right" | undefined; bgcolor?: string | undefined; border?: number | undefined; cellPadding?: number | string | undefined; cellSpacing?: number | string | undefined; frame?: boolean | undefined; rules?: "none" | "groups" | "rows" | "columns" | "all" | undefined; summary?: string | undefined; width?: number | string | undefined; } interface TextareaHTMLAttributes extends HTMLAttributes { autoComplete?: string | undefined; autoFocus?: boolean | undefined; cols?: number | undefined; dirName?: string | undefined; disabled?: boolean | undefined; form?: string | undefined; maxLength?: number | undefined; minLength?: number | undefined; name?: string | undefined; placeholder?: string | undefined; readOnly?: boolean | undefined; required?: boolean | undefined; rows?: number | undefined; value?: string | ReadonlyArray | number | undefined; wrap?: string | undefined; onChange?: ChangeEventHandler | undefined; } interface TdHTMLAttributes extends HTMLAttributes { align?: "left" | "center" | "right" | "justify" | "char" | undefined; colSpan?: number | undefined; headers?: string | undefined; rowSpan?: number | undefined; scope?: string | undefined; abbr?: string | undefined; height?: number | string | undefined; width?: number | string | undefined; valign?: "top" | "middle" | "bottom" | "baseline" | undefined; } interface ThHTMLAttributes extends HTMLAttributes { align?: "left" | "center" | "right" | "justify" | "char" | undefined; colSpan?: number | undefined; headers?: string | undefined; rowSpan?: number | undefined; scope?: string | undefined; abbr?: string | undefined; } interface TimeHTMLAttributes extends HTMLAttributes { dateTime?: string | undefined; } interface TrackHTMLAttributes extends HTMLAttributes { default?: boolean | undefined; kind?: string | undefined; label?: string | undefined; src?: string | undefined; srcLang?: string | undefined; } interface VideoHTMLAttributes extends MediaHTMLAttributes { height?: number | string | undefined; playsInline?: boolean | undefined; poster?: string | undefined; width?: number | string | undefined; disablePictureInPicture?: boolean | undefined; disableRemotePlayback?: boolean | undefined; } // this list is "complete" in that it contains every SVG attribute // that React supports, but the types can be improved. // Full list here: https://facebook.github.io/react/docs/dom-elements.html // // The three broad type categories are (in order of restrictiveness): // - "number | string" // - "string" // - union of string literals interface SVGAttributes extends AriaAttributes, DOMAttributes { // Attributes which also defined in HTMLAttributes // See comment in SVGDOMPropertyConfig.js className?: string | undefined; color?: string | undefined; height?: number | string | undefined; id?: string | undefined; lang?: string | undefined; max?: number | string | undefined; media?: string | undefined; method?: string | undefined; min?: number | string | undefined; name?: string | undefined; style?: CSSProperties | undefined; target?: string | undefined; type?: string | undefined; width?: number | string | undefined; // Other HTML properties supported by SVG elements in browsers role?: AriaRole | undefined; tabIndex?: number | undefined; crossOrigin?: "anonymous" | "use-credentials" | "" | undefined; // SVG Specific attributes accentHeight?: number | string | undefined; accumulate?: "none" | "sum" | undefined; additive?: "replace" | "sum" | undefined; alignmentBaseline?: "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" | "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit" | undefined; allowReorder?: "no" | "yes" | undefined; alphabetic?: number | string | undefined; amplitude?: number | string | undefined; arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined; ascent?: number | string | undefined; attributeName?: string | undefined; attributeType?: string | undefined; autoReverse?: Booleanish | undefined; azimuth?: number | string | undefined; baseFrequency?: number | string | undefined; baselineShift?: number | string | undefined; baseProfile?: number | string | undefined; bbox?: number | string | undefined; begin?: number | string | undefined; bias?: number | string | undefined; by?: number | string | undefined; calcMode?: number | string | undefined; capHeight?: number | string | undefined; clip?: number | string | undefined; clipPath?: string | undefined; clipPathUnits?: number | string | undefined; clipRule?: number | string | undefined; colorInterpolation?: number | string | undefined; colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined; colorProfile?: number | string | undefined; colorRendering?: number | string | undefined; contentScriptType?: number | string | undefined; contentStyleType?: number | string | undefined; cursor?: number | string | undefined; cx?: number | string | undefined; cy?: number | string | undefined; d?: string | undefined; decelerate?: number | string | undefined; descent?: number | string | undefined; diffuseConstant?: number | string | undefined; direction?: number | string | undefined; display?: number | string | undefined; divisor?: number | string | undefined; dominantBaseline?: number | string | undefined; dur?: number | string | undefined; dx?: number | string | undefined; dy?: number | string | undefined; edgeMode?: number | string | undefined; elevation?: number | string | undefined; enableBackground?: number | string | undefined; end?: number | string | undefined; exponent?: number | string | undefined; externalResourcesRequired?: Booleanish | undefined; fill?: string | undefined; fillOpacity?: number | string | undefined; fillRule?: "nonzero" | "evenodd" | "inherit" | undefined; filter?: string | undefined; filterRes?: number | string | undefined; filterUnits?: number | string | undefined; floodColor?: number | string | undefined; floodOpacity?: number | string | undefined; focusable?: Booleanish | "auto" | undefined; fontFamily?: string | undefined; fontSize?: number | string | undefined; fontSizeAdjust?: number | string | undefined; fontStretch?: number | string | undefined; fontStyle?: number | string | undefined; fontVariant?: number | string | undefined; fontWeight?: number | string | undefined; format?: number | string | undefined; fr?: number | string | undefined; from?: number | string | undefined; fx?: number | string | undefined; fy?: number | string | undefined; g1?: number | string | undefined; g2?: number | string | undefined; glyphName?: number | string | undefined; glyphOrientationHorizontal?: number | string | undefined; glyphOrientationVertical?: number | string | undefined; glyphRef?: number | string | undefined; gradientTransform?: string | undefined; gradientUnits?: string | undefined; hanging?: number | string | undefined; horizAdvX?: number | string | undefined; horizOriginX?: number | string | undefined; href?: string | undefined; ideographic?: number | string | undefined; imageRendering?: number | string | undefined; in2?: number | string | undefined; in?: string | undefined; intercept?: number | string | undefined; k1?: number | string | undefined; k2?: number | string | undefined; k3?: number | string | undefined; k4?: number | string | undefined; k?: number | string | undefined; kernelMatrix?: number | string | undefined; kernelUnitLength?: number | string | undefined; kerning?: number | string | undefined; keyPoints?: number | string | undefined; keySplines?: number | string | undefined; keyTimes?: number | string | undefined; lengthAdjust?: number | string | undefined; letterSpacing?: number | string | undefined; lightingColor?: number | string | undefined; limitingConeAngle?: number | string | undefined; local?: number | string | undefined; markerEnd?: string | undefined; markerHeight?: number | string | undefined; markerMid?: string | undefined; markerStart?: string | undefined; markerUnits?: number | string | undefined; markerWidth?: number | string | undefined; mask?: string | undefined; maskContentUnits?: number | string | undefined; maskUnits?: number | string | undefined; mathematical?: number | string | undefined; mode?: number | string | undefined; numOctaves?: number | string | undefined; offset?: number | string | undefined; opacity?: number | string | undefined; operator?: number | string | undefined; order?: number | string | undefined; orient?: number | string | undefined; orientation?: number | string | undefined; origin?: number | string | undefined; overflow?: number | string | undefined; overlinePosition?: number | string | undefined; overlineThickness?: number | string | undefined; paintOrder?: number | string | undefined; panose1?: number | string | undefined; path?: string | undefined; pathLength?: number | string | undefined; patternContentUnits?: string | undefined; patternTransform?: number | string | undefined; patternUnits?: string | undefined; pointerEvents?: number | string | undefined; points?: string | undefined; pointsAtX?: number | string | undefined; pointsAtY?: number | string | undefined; pointsAtZ?: number | string | undefined; preserveAlpha?: Booleanish | undefined; preserveAspectRatio?: string | undefined; primitiveUnits?: number | string | undefined; r?: number | string | undefined; radius?: number | string | undefined; refX?: number | string | undefined; refY?: number | string | undefined; renderingIntent?: number | string | undefined; repeatCount?: number | string | undefined; repeatDur?: number | string | undefined; requiredExtensions?: number | string | undefined; requiredFeatures?: number | string | undefined; restart?: number | string | undefined; result?: string | undefined; rotate?: number | string | undefined; rx?: number | string | undefined; ry?: number | string | undefined; scale?: number | string | undefined; seed?: number | string | undefined; shapeRendering?: number | string | undefined; slope?: number | string | undefined; spacing?: number | string | undefined; specularConstant?: number | string | undefined; specularExponent?: number | string | undefined; speed?: number | string | undefined; spreadMethod?: string | undefined; startOffset?: number | string | undefined; stdDeviation?: number | string | undefined; stemh?: number | string | undefined; stemv?: number | string | undefined; stitchTiles?: number | string | undefined; stopColor?: string | undefined; stopOpacity?: number | string | undefined; strikethroughPosition?: number | string | undefined; strikethroughThickness?: number | string | undefined; string?: number | string | undefined; stroke?: string | undefined; strokeDasharray?: string | number | undefined; strokeDashoffset?: string | number | undefined; strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined; strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined; strokeMiterlimit?: number | string | undefined; strokeOpacity?: number | string | undefined; strokeWidth?: number | string | undefined; surfaceScale?: number | string | undefined; systemLanguage?: number | string | undefined; tableValues?: number | string | undefined; targetX?: number | string | undefined; targetY?: number | string | undefined; textAnchor?: string | undefined; textDecoration?: number | string | undefined; textLength?: number | string | undefined; textRendering?: number | string | undefined; to?: number | string | undefined; transform?: string | undefined; u1?: number | string | undefined; u2?: number | string | undefined; underlinePosition?: number | string | undefined; underlineThickness?: number | string | undefined; unicode?: number | string | undefined; unicodeBidi?: number | string | undefined; unicodeRange?: number | string | undefined; unitsPerEm?: number | string | undefined; vAlphabetic?: number | string | undefined; values?: string | undefined; vectorEffect?: number | string | undefined; version?: string | undefined; vertAdvY?: number | string | undefined; vertOriginX?: number | string | undefined; vertOriginY?: number | string | undefined; vHanging?: number | string | undefined; vIdeographic?: number | string | undefined; viewBox?: string | undefined; viewTarget?: number | string | undefined; visibility?: number | string | undefined; vMathematical?: number | string | undefined; widths?: number | string | undefined; wordSpacing?: number | string | undefined; writingMode?: number | string | undefined; x1?: number | string | undefined; x2?: number | string | undefined; x?: number | string | undefined; xChannelSelector?: string | undefined; xHeight?: number | string | undefined; xlinkActuate?: string | undefined; xlinkArcrole?: string | undefined; xlinkHref?: string | undefined; xlinkRole?: string | undefined; xlinkShow?: string | undefined; xlinkTitle?: string | undefined; xlinkType?: string | undefined; xmlBase?: string | undefined; xmlLang?: string | undefined; xmlns?: string | undefined; xmlnsXlink?: string | undefined; xmlSpace?: string | undefined; y1?: number | string | undefined; y2?: number | string | undefined; y?: number | string | undefined; yChannelSelector?: string | undefined; z?: number | string | undefined; zoomAndPan?: string | undefined; } interface WebViewHTMLAttributes extends HTMLAttributes { allowFullScreen?: boolean | undefined; allowpopups?: boolean | undefined; autoFocus?: boolean | undefined; autosize?: boolean | undefined; blinkfeatures?: string | undefined; disableblinkfeatures?: string | undefined; disableguestresize?: boolean | undefined; disablewebsecurity?: boolean | undefined; guestinstance?: string | undefined; httpreferrer?: string | undefined; nodeintegration?: boolean | undefined; partition?: string | undefined; plugins?: boolean | undefined; preload?: string | undefined; src?: string | undefined; useragent?: string | undefined; webpreferences?: string | undefined; } // // React.DOM // ---------------------------------------------------------------------- interface ReactHTML { a: DetailedHTMLFactory, HTMLAnchorElement>; abbr: DetailedHTMLFactory, HTMLElement>; address: DetailedHTMLFactory, HTMLElement>; area: DetailedHTMLFactory, HTMLAreaElement>; article: DetailedHTMLFactory, HTMLElement>; aside: DetailedHTMLFactory, HTMLElement>; audio: DetailedHTMLFactory, HTMLAudioElement>; b: DetailedHTMLFactory, HTMLElement>; base: DetailedHTMLFactory, HTMLBaseElement>; bdi: DetailedHTMLFactory, HTMLElement>; bdo: DetailedHTMLFactory, HTMLElement>; big: DetailedHTMLFactory, HTMLElement>; blockquote: DetailedHTMLFactory, HTMLQuoteElement>; body: DetailedHTMLFactory, HTMLBodyElement>; br: DetailedHTMLFactory, HTMLBRElement>; button: DetailedHTMLFactory, HTMLButtonElement>; canvas: DetailedHTMLFactory, HTMLCanvasElement>; caption: DetailedHTMLFactory, HTMLElement>; cite: DetailedHTMLFactory, HTMLElement>; code: DetailedHTMLFactory, HTMLElement>; col: DetailedHTMLFactory, HTMLTableColElement>; colgroup: DetailedHTMLFactory, HTMLTableColElement>; data: DetailedHTMLFactory, HTMLDataElement>; datalist: DetailedHTMLFactory, HTMLDataListElement>; dd: DetailedHTMLFactory, HTMLElement>; del: DetailedHTMLFactory, HTMLModElement>; details: DetailedHTMLFactory, HTMLDetailsElement>; dfn: DetailedHTMLFactory, HTMLElement>; dialog: DetailedHTMLFactory, HTMLDialogElement>; div: DetailedHTMLFactory, HTMLDivElement>; dl: DetailedHTMLFactory, HTMLDListElement>; dt: DetailedHTMLFactory, HTMLElement>; em: DetailedHTMLFactory, HTMLElement>; embed: DetailedHTMLFactory, HTMLEmbedElement>; fieldset: DetailedHTMLFactory, HTMLFieldSetElement>; figcaption: DetailedHTMLFactory, HTMLElement>; figure: DetailedHTMLFactory, HTMLElement>; footer: DetailedHTMLFactory, HTMLElement>; form: DetailedHTMLFactory, HTMLFormElement>; h1: DetailedHTMLFactory, HTMLHeadingElement>; h2: DetailedHTMLFactory, HTMLHeadingElement>; h3: DetailedHTMLFactory, HTMLHeadingElement>; h4: DetailedHTMLFactory, HTMLHeadingElement>; h5: DetailedHTMLFactory, HTMLHeadingElement>; h6: DetailedHTMLFactory, HTMLHeadingElement>; head: DetailedHTMLFactory, HTMLHeadElement>; header: DetailedHTMLFactory, HTMLElement>; hgroup: DetailedHTMLFactory, HTMLElement>; hr: DetailedHTMLFactory, HTMLHRElement>; html: DetailedHTMLFactory, HTMLHtmlElement>; i: DetailedHTMLFactory, HTMLElement>; iframe: DetailedHTMLFactory, HTMLIFrameElement>; img: DetailedHTMLFactory, HTMLImageElement>; input: DetailedHTMLFactory, HTMLInputElement>; ins: DetailedHTMLFactory, HTMLModElement>; kbd: DetailedHTMLFactory, HTMLElement>; keygen: DetailedHTMLFactory, HTMLElement>; label: DetailedHTMLFactory, HTMLLabelElement>; legend: DetailedHTMLFactory, HTMLLegendElement>; li: DetailedHTMLFactory, HTMLLIElement>; link: DetailedHTMLFactory, HTMLLinkElement>; main: DetailedHTMLFactory, HTMLElement>; map: DetailedHTMLFactory, HTMLMapElement>; mark: DetailedHTMLFactory, HTMLElement>; menu: DetailedHTMLFactory, HTMLElement>; menuitem: DetailedHTMLFactory, HTMLElement>; meta: DetailedHTMLFactory, HTMLMetaElement>; meter: DetailedHTMLFactory, HTMLMeterElement>; nav: DetailedHTMLFactory, HTMLElement>; noscript: DetailedHTMLFactory, HTMLElement>; object: DetailedHTMLFactory, HTMLObjectElement>; ol: DetailedHTMLFactory, HTMLOListElement>; optgroup: DetailedHTMLFactory, HTMLOptGroupElement>; option: DetailedHTMLFactory, HTMLOptionElement>; output: DetailedHTMLFactory, HTMLOutputElement>; p: DetailedHTMLFactory, HTMLParagraphElement>; param: DetailedHTMLFactory, HTMLParamElement>; picture: DetailedHTMLFactory, HTMLElement>; pre: DetailedHTMLFactory, HTMLPreElement>; progress: DetailedHTMLFactory, HTMLProgressElement>; q: DetailedHTMLFactory, HTMLQuoteElement>; rp: DetailedHTMLFactory, HTMLElement>; rt: DetailedHTMLFactory, HTMLElement>; ruby: DetailedHTMLFactory, HTMLElement>; s: DetailedHTMLFactory, HTMLElement>; samp: DetailedHTMLFactory, HTMLElement>; slot: DetailedHTMLFactory, HTMLSlotElement>; script: DetailedHTMLFactory, HTMLScriptElement>; section: DetailedHTMLFactory, HTMLElement>; select: DetailedHTMLFactory, HTMLSelectElement>; small: DetailedHTMLFactory, HTMLElement>; source: DetailedHTMLFactory, HTMLSourceElement>; span: DetailedHTMLFactory, HTMLSpanElement>; strong: DetailedHTMLFactory, HTMLElement>; style: DetailedHTMLFactory, HTMLStyleElement>; sub: DetailedHTMLFactory, HTMLElement>; summary: DetailedHTMLFactory, HTMLElement>; sup: DetailedHTMLFactory, HTMLElement>; table: DetailedHTMLFactory, HTMLTableElement>; template: DetailedHTMLFactory, HTMLTemplateElement>; tbody: DetailedHTMLFactory, HTMLTableSectionElement>; td: DetailedHTMLFactory, HTMLTableDataCellElement>; textarea: DetailedHTMLFactory, HTMLTextAreaElement>; tfoot: DetailedHTMLFactory, HTMLTableSectionElement>; th: DetailedHTMLFactory, HTMLTableHeaderCellElement>; thead: DetailedHTMLFactory, HTMLTableSectionElement>; time: DetailedHTMLFactory, HTMLTimeElement>; title: DetailedHTMLFactory, HTMLTitleElement>; tr: DetailedHTMLFactory, HTMLTableRowElement>; track: DetailedHTMLFactory, HTMLTrackElement>; u: DetailedHTMLFactory, HTMLElement>; ul: DetailedHTMLFactory, HTMLUListElement>; "var": DetailedHTMLFactory, HTMLElement>; video: DetailedHTMLFactory, HTMLVideoElement>; wbr: DetailedHTMLFactory, HTMLElement>; webview: DetailedHTMLFactory, HTMLWebViewElement>; } interface ReactSVG { animate: SVGFactory; circle: SVGFactory; clipPath: SVGFactory; defs: SVGFactory; desc: SVGFactory; ellipse: SVGFactory; feBlend: SVGFactory; feColorMatrix: SVGFactory; feComponentTransfer: SVGFactory; feComposite: SVGFactory; feConvolveMatrix: SVGFactory; feDiffuseLighting: SVGFactory; feDisplacementMap: SVGFactory; feDistantLight: SVGFactory; feDropShadow: SVGFactory; feFlood: SVGFactory; feFuncA: SVGFactory; feFuncB: SVGFactory; feFuncG: SVGFactory; feFuncR: SVGFactory; feGaussianBlur: SVGFactory; feImage: SVGFactory; feMerge: SVGFactory; feMergeNode: SVGFactory; feMorphology: SVGFactory; feOffset: SVGFactory; fePointLight: SVGFactory; feSpecularLighting: SVGFactory; feSpotLight: SVGFactory; feTile: SVGFactory; feTurbulence: SVGFactory; filter: SVGFactory; foreignObject: SVGFactory; g: SVGFactory; image: SVGFactory; line: SVGFactory; linearGradient: SVGFactory; marker: SVGFactory; mask: SVGFactory; metadata: SVGFactory; path: SVGFactory; pattern: SVGFactory; polygon: SVGFactory; polyline: SVGFactory; radialGradient: SVGFactory; rect: SVGFactory; stop: SVGFactory; svg: SVGFactory; switch: SVGFactory; symbol: SVGFactory; text: SVGFactory; textPath: SVGFactory; tspan: SVGFactory; use: SVGFactory; view: SVGFactory; } interface ReactDOM extends ReactHTML, ReactSVG { } // // React.PropTypes // ---------------------------------------------------------------------- type Validator = PropTypes.Validator; type Requireable = PropTypes.Requireable; type ValidationMap = PropTypes.ValidationMap; type WeakValidationMap = { [K in keyof T]?: null extends T[K] ? Validator : undefined extends T[K] ? Validator : Validator }; interface ReactPropTypes { any: typeof PropTypes.any; array: typeof PropTypes.array; bool: typeof PropTypes.bool; func: typeof PropTypes.func; number: typeof PropTypes.number; object: typeof PropTypes.object; string: typeof PropTypes.string; node: typeof PropTypes.node; element: typeof PropTypes.element; instanceOf: typeof PropTypes.instanceOf; oneOf: typeof PropTypes.oneOf; oneOfType: typeof PropTypes.oneOfType; arrayOf: typeof PropTypes.arrayOf; objectOf: typeof PropTypes.objectOf; shape: typeof PropTypes.shape; exact: typeof PropTypes.exact; } // // React.Children // ---------------------------------------------------------------------- /** * @deprecated - Use `typeof React.Children` instead. */ // Sync with type of `const Children`. interface ReactChildren { map(children: C | ReadonlyArray, fn: (child: C, index: number) => T): C extends null | undefined ? C : Array>; forEach(children: C | ReadonlyArray, fn: (child: C, index: number) => void): void; count(children: any): number; only(children: C): C extends any[] ? never : C; toArray(children: ReactNode | ReactNode[]): Array>; } // // 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; } // // Error Interfaces // ---------------------------------------------------------------------- interface ErrorInfo { /** * Captures which component contained the exception, and its ancestors. */ componentStack: string; } } // naked 'any' type in a conditional type will short circuit and union both the then/else branches // so boolean is only resolved for T = any type IsExactlyAny = boolean extends (T extends never ? true : false) ? true : false; type ExactlyAnyPropertyKeys = { [K in keyof T]: IsExactlyAny extends true ? K : never }[keyof T]; type NotExactlyAnyPropertyKeys = Exclude>; // Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any type MergePropTypes = // Distribute over P in case it is a union type P extends any // If props is type any, use propTypes definitions ? IsExactlyAny

extends true ? T : // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened string extends keyof P ? P : // Prefer declared types which are not exactly any & Pick> // For props which are exactly any, use the type inferred from propTypes if present & Pick>> // Keep leftover props not specified in propTypes & Pick> : never; type InexactPartial = { [K in keyof T]?: T[K] | undefined }; // Any prop that has a default prop becomes optional, but its type is unchanged // Undeclared default props are augmented into the resulting allowable attributes // If declared props have indexed properties, ignore default props entirely as keyof gets widened // Wrap in an outer-level conditional type to allow distribution over props that are unions type Defaultize = P extends any ? string extends keyof P ? P : & Pick> & InexactPartial>> & InexactPartial>> : never; type ReactManagedAttributes = C extends { propTypes: infer T; defaultProps: infer D; } ? Defaultize>, D> : C extends { propTypes: infer T; } ? MergePropTypes> : C extends { defaultProps: infer D; } ? Defaultize : P; declare global { namespace JSX { interface Element extends React.ReactElement { } interface ElementClass extends React.Component { render(): React.ReactNode; } interface ElementAttributesProperty { props: {}; } interface ElementChildrenAttribute { children: {}; } // We can't recurse forever because `type` can't be self-referential; // let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa type LibraryManagedAttributes = C extends React.MemoExoticComponent | React.LazyExoticComponent ? T extends React.MemoExoticComponent | React.LazyExoticComponent ? ReactManagedAttributes : ReactManagedAttributes : ReactManagedAttributes; interface IntrinsicAttributes extends React.Attributes { } interface IntrinsicClassAttributes extends React.ClassAttributes { } interface IntrinsicElements { // HTML a: React.DetailedHTMLProps, HTMLAnchorElement>; abbr: React.DetailedHTMLProps, HTMLElement>; address: React.DetailedHTMLProps, HTMLElement>; area: React.DetailedHTMLProps, HTMLAreaElement>; article: React.DetailedHTMLProps, HTMLElement>; aside: React.DetailedHTMLProps, HTMLElement>; audio: React.DetailedHTMLProps, HTMLAudioElement>; b: React.DetailedHTMLProps, HTMLElement>; base: React.DetailedHTMLProps, HTMLBaseElement>; bdi: React.DetailedHTMLProps, HTMLElement>; bdo: React.DetailedHTMLProps, HTMLElement>; big: React.DetailedHTMLProps, HTMLElement>; blockquote: React.DetailedHTMLProps, HTMLQuoteElement>; body: React.DetailedHTMLProps, HTMLBodyElement>; br: React.DetailedHTMLProps, HTMLBRElement>; button: React.DetailedHTMLProps, HTMLButtonElement>; canvas: React.DetailedHTMLProps, HTMLCanvasElement>; caption: React.DetailedHTMLProps, HTMLElement>; cite: React.DetailedHTMLProps, HTMLElement>; code: React.DetailedHTMLProps, HTMLElement>; col: React.DetailedHTMLProps, HTMLTableColElement>; colgroup: React.DetailedHTMLProps, HTMLTableColElement>; data: React.DetailedHTMLProps, HTMLDataElement>; datalist: React.DetailedHTMLProps, HTMLDataListElement>; dd: React.DetailedHTMLProps, HTMLElement>; del: React.DetailedHTMLProps, HTMLModElement>; details: React.DetailedHTMLProps, HTMLDetailsElement>; dfn: React.DetailedHTMLProps, HTMLElement>; dialog: React.DetailedHTMLProps, HTMLDialogElement>; div: React.DetailedHTMLProps, HTMLDivElement>; dl: React.DetailedHTMLProps, HTMLDListElement>; dt: React.DetailedHTMLProps, HTMLElement>; em: React.DetailedHTMLProps, HTMLElement>; embed: React.DetailedHTMLProps, HTMLEmbedElement>; fieldset: React.DetailedHTMLProps, HTMLFieldSetElement>; figcaption: React.DetailedHTMLProps, HTMLElement>; figure: React.DetailedHTMLProps, HTMLElement>; footer: React.DetailedHTMLProps, HTMLElement>; form: React.DetailedHTMLProps, HTMLFormElement>; h1: React.DetailedHTMLProps, HTMLHeadingElement>; h2: React.DetailedHTMLProps, HTMLHeadingElement>; h3: React.DetailedHTMLProps, HTMLHeadingElement>; h4: React.DetailedHTMLProps, HTMLHeadingElement>; h5: React.DetailedHTMLProps, HTMLHeadingElement>; h6: React.DetailedHTMLProps, HTMLHeadingElement>; head: React.DetailedHTMLProps, HTMLHeadElement>; header: React.DetailedHTMLProps, HTMLElement>; hgroup: React.DetailedHTMLProps, HTMLElement>; hr: React.DetailedHTMLProps, HTMLHRElement>; html: React.DetailedHTMLProps, HTMLHtmlElement>; i: React.DetailedHTMLProps, HTMLElement>; iframe: React.DetailedHTMLProps, HTMLIFrameElement>; img: React.DetailedHTMLProps, HTMLImageElement>; input: React.DetailedHTMLProps, HTMLInputElement>; ins: React.DetailedHTMLProps, HTMLModElement>; kbd: React.DetailedHTMLProps, HTMLElement>; keygen: React.DetailedHTMLProps, HTMLElement>; label: React.DetailedHTMLProps, HTMLLabelElement>; legend: React.DetailedHTMLProps, HTMLLegendElement>; li: React.DetailedHTMLProps, HTMLLIElement>; link: React.DetailedHTMLProps, HTMLLinkElement>; main: React.DetailedHTMLProps, HTMLElement>; map: React.DetailedHTMLProps, HTMLMapElement>; mark: React.DetailedHTMLProps, HTMLElement>; menu: React.DetailedHTMLProps, HTMLElement>; menuitem: React.DetailedHTMLProps, HTMLElement>; meta: React.DetailedHTMLProps, HTMLMetaElement>; meter: React.DetailedHTMLProps, HTMLMeterElement>; nav: React.DetailedHTMLProps, HTMLElement>; noindex: React.DetailedHTMLProps, HTMLElement>; noscript: React.DetailedHTMLProps, HTMLElement>; object: React.DetailedHTMLProps, HTMLObjectElement>; ol: React.DetailedHTMLProps, HTMLOListElement>; optgroup: React.DetailedHTMLProps, HTMLOptGroupElement>; option: React.DetailedHTMLProps, HTMLOptionElement>; output: React.DetailedHTMLProps, HTMLOutputElement>; p: React.DetailedHTMLProps, HTMLParagraphElement>; param: React.DetailedHTMLProps, HTMLParamElement>; picture: React.DetailedHTMLProps, HTMLElement>; pre: React.DetailedHTMLProps, HTMLPreElement>; progress: React.DetailedHTMLProps, HTMLProgressElement>; q: React.DetailedHTMLProps, HTMLQuoteElement>; rp: React.DetailedHTMLProps, HTMLElement>; rt: React.DetailedHTMLProps, HTMLElement>; ruby: React.DetailedHTMLProps, HTMLElement>; s: React.DetailedHTMLProps, HTMLElement>; samp: React.DetailedHTMLProps, HTMLElement>; slot: React.DetailedHTMLProps, HTMLSlotElement>; script: React.DetailedHTMLProps, HTMLScriptElement>; section: React.DetailedHTMLProps, HTMLElement>; select: React.DetailedHTMLProps, HTMLSelectElement>; small: React.DetailedHTMLProps, HTMLElement>; source: React.DetailedHTMLProps, HTMLSourceElement>; span: React.DetailedHTMLProps, HTMLSpanElement>; strong: React.DetailedHTMLProps, HTMLElement>; style: React.DetailedHTMLProps, HTMLStyleElement>; sub: React.DetailedHTMLProps, HTMLElement>; summary: React.DetailedHTMLProps, HTMLElement>; sup: React.DetailedHTMLProps, HTMLElement>; table: React.DetailedHTMLProps, HTMLTableElement>; template: React.DetailedHTMLProps, HTMLTemplateElement>; tbody: React.DetailedHTMLProps, HTMLTableSectionElement>; td: React.DetailedHTMLProps, HTMLTableDataCellElement>; textarea: React.DetailedHTMLProps, HTMLTextAreaElement>; tfoot: React.DetailedHTMLProps, HTMLTableSectionElement>; th: React.DetailedHTMLProps, HTMLTableHeaderCellElement>; thead: React.DetailedHTMLProps, HTMLTableSectionElement>; time: React.DetailedHTMLProps, HTMLTimeElement>; title: React.DetailedHTMLProps, HTMLTitleElement>; tr: React.DetailedHTMLProps, HTMLTableRowElement>; track: React.DetailedHTMLProps, HTMLTrackElement>; u: React.DetailedHTMLProps, HTMLElement>; ul: React.DetailedHTMLProps, HTMLUListElement>; "var": React.DetailedHTMLProps, HTMLElement>; video: React.DetailedHTMLProps, HTMLVideoElement>; wbr: React.DetailedHTMLProps, HTMLElement>; webview: React.DetailedHTMLProps, HTMLWebViewElement>; // SVG svg: React.SVGProps; animate: React.SVGProps; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now. animateMotion: React.SVGProps; animateTransform: React.SVGProps; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now. circle: React.SVGProps; clipPath: React.SVGProps; defs: React.SVGProps; desc: React.SVGProps; ellipse: React.SVGProps; feBlend: React.SVGProps; feColorMatrix: React.SVGProps; feComponentTransfer: React.SVGProps; feComposite: React.SVGProps; feConvolveMatrix: React.SVGProps; feDiffuseLighting: React.SVGProps; feDisplacementMap: React.SVGProps; feDistantLight: React.SVGProps; feDropShadow: React.SVGProps; feFlood: React.SVGProps; feFuncA: React.SVGProps; feFuncB: React.SVGProps; feFuncG: React.SVGProps; feFuncR: React.SVGProps; feGaussianBlur: React.SVGProps; feImage: React.SVGProps; feMerge: React.SVGProps; feMergeNode: React.SVGProps; feMorphology: React.SVGProps; feOffset: React.SVGProps; fePointLight: React.SVGProps; feSpecularLighting: React.SVGProps; feSpotLight: React.SVGProps; feTile: React.SVGProps; feTurbulence: React.SVGProps; filter: React.SVGProps; foreignObject: React.SVGProps; g: React.SVGProps; image: React.SVGProps; line: React.SVGProps; linearGradient: React.SVGProps; marker: React.SVGProps; mask: React.SVGProps; metadata: React.SVGProps; mpath: React.SVGProps; path: React.SVGProps; pattern: React.SVGProps; polygon: React.SVGProps; polyline: React.SVGProps; radialGradient: React.SVGProps; rect: React.SVGProps; stop: React.SVGProps; switch: React.SVGProps; symbol: React.SVGProps; text: React.SVGProps; textPath: React.SVGProps; tspan: React.SVGProps; use: React.SVGProps; view: React.SVGProps; } } }