UNPKG

152 kBTypeScriptView Raw
1// Type definitions for React 17.0
2// Project: http://facebook.github.io/react/
3// Definitions by: Asana <https://asana.com>
4// AssureSign <http://www.assuresign.com>
5// Microsoft <https://microsoft.com>
6// John Reilly <https://github.com/johnnyreilly>
7// Benoit Benezech <https://github.com/bbenezech>
8// Patricio Zavolinsky <https://github.com/pzavolinsky>
9// Eric Anderson <https://github.com/ericanderson>
10// Dovydas Navickas <https://github.com/DovydasNavickas>
11// Josh Rutherford <https://github.com/theruther4d>
12// Guilherme Hübner <https://github.com/guilhermehubner>
13// Ferdy Budhidharma <https://github.com/ferdaber>
14// Johann Rakotoharisoa <https://github.com/jrakotoharisoa>
15// Olivier Pascal <https://github.com/pascaloliv>
16// Martin Hochel <https://github.com/hotell>
17// Frank Li <https://github.com/franklixuefei>
18// Jessica Franco <https://github.com/Jessidhia>
19// Saransh Kataria <https://github.com/saranshkataria>
20// Kanitkorn Sujautra <https://github.com/lukyth>
21// Sebastian Silbermann <https://github.com/eps1lon>
22// Kyle Scully <https://github.com/zieka>
23// Cong Zhang <https://github.com/dancerphil>
24// Dimitri Mitropoulos <https://github.com/dimitropoulos>
25// JongChan Choi <https://github.com/disjukr>
26// Victor Magalhães <https://github.com/vhfmag>
27// Dale Tan <https://github.com/hellatan>
28// Priyanshu Rav <https://github.com/priyanshurav>
29// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
30// TypeScript Version: 2.8
31
32// NOTE: Users of the upcoming React 18 release should add a reference
33// to 'react/next' in their project. See next.d.ts's top comment
34// for reference and documentation on how exactly to do it.
35
36// NOTE: Users of the `experimental` builds of React should add a reference
37// to 'react/experimental' in their project. See experimental.d.ts's top comment
38// for reference and documentation on how exactly to do it.
39
40/// <reference path="global.d.ts" />
41
42import * as CSS from 'csstype';
43import * as PropTypes from 'prop-types';
44import { Interaction as SchedulerInteraction } from 'scheduler/tracing';
45
46type NativeAnimationEvent = AnimationEvent;
47type NativeClipboardEvent = ClipboardEvent;
48type NativeCompositionEvent = CompositionEvent;
49type NativeDragEvent = DragEvent;
50type NativeFocusEvent = FocusEvent;
51type NativeKeyboardEvent = KeyboardEvent;
52type NativeMouseEvent = MouseEvent;
53type NativeTouchEvent = TouchEvent;
54type NativePointerEvent = PointerEvent;
55type NativeTransitionEvent = TransitionEvent;
56type NativeUIEvent = UIEvent;
57type NativeWheelEvent = WheelEvent;
58type Booleanish = boolean | 'true' | 'false';
59
60declare const UNDEFINED_VOID_ONLY: unique symbol;
61// Destructors are only allowed to return void.
62type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };
63
64// tslint:disable-next-line:export-just-namespace
65export = React;
66export as namespace React;
67
68declare namespace React {
69 //
70 // React Elements
71 // ----------------------------------------------------------------------
72
73 type ElementType<P = any> =
74 {
75 [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never
76 }[keyof JSX.IntrinsicElements] |
77 ComponentType<P>;
78 /**
79 * @deprecated Please use `ElementType`
80 */
81 type ReactType<P = any> = ElementType<P>;
82 type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
83
84 type JSXElementConstructor<P> =
85 | ((props: P) => ReactElement<any, any> | null)
86 | (new (props: P) => Component<any, any>);
87
88 interface RefObject<T> {
89 readonly current: T | null;
90 }
91 type RefCallback<T> = { bivarianceHack(instance: T | null): void }["bivarianceHack"];
92 type Ref<T> = RefCallback<T> | RefObject<T> | null;
93 type LegacyRef<T> = string | Ref<T>;
94 /**
95 * Gets the instance type for a React element. The instance will be different for various component types:
96 *
97 * - React class components will be the class instance. So if you had `class Foo extends React.Component<{}> {}`
98 * and used `React.ElementRef<typeof Foo>` then the type would be the instance of `Foo`.
99 * - React stateless functional components do not have a backing instance and so `React.ElementRef<typeof Bar>`
100 * (when `Bar` is `function Bar() {}`) will give you the `undefined` type.
101 * - JSX intrinsics like `div` will give you their DOM instance. For `React.ElementRef<'div'>` that would be
102 * `HTMLDivElement`. For `React.ElementRef<'input'>` that would be `HTMLInputElement`.
103 * - React stateless functional components that forward a `ref` will give you the `ElementRef` of the forwarded
104 * to component.
105 *
106 * `C` must be the type _of_ a React component so you need to use typeof as in React.ElementRef<typeof MyComponent>.
107 *
108 * @todo In Flow, this works a little different with forwarded refs and the `AbstractComponent` that
109 * `React.forwardRef()` returns.
110 */
111 type ElementRef<
112 C extends
113 | ForwardRefExoticComponent<any>
114 | { new (props: any): Component<any> }
115 | ((props: any, context?: any) => ReactElement | null)
116 | keyof JSX.IntrinsicElements
117 > =
118 // need to check first if `ref` is a valid prop for ts@3.0
119 // otherwise it will infer `{}` instead of `never`
120 "ref" extends keyof ComponentPropsWithRef<C>
121 ? NonNullable<ComponentPropsWithRef<C>["ref"]> extends Ref<
122 infer Instance
123 >
124 ? Instance
125 : never
126 : never;
127
128 type ComponentState = any;
129
130 type Key = string | number;
131
132 /**
133 * @internal You shouldn't need to use this type since you never see these attributes
134 * inside your component or have to validate them.
135 */
136 interface Attributes {
137 key?: Key | null | undefined;
138 }
139 interface RefAttributes<T> extends Attributes {
140 ref?: Ref<T> | undefined;
141 }
142 interface ClassAttributes<T> extends Attributes {
143 ref?: LegacyRef<T> | undefined;
144 }
145
146 interface ReactElement<P = any, T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>> {
147 type: T;
148 props: P;
149 key: Key | null;
150 }
151
152 interface ReactComponentElement<
153 T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
154 P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, 'key' | 'ref'>>
155 > extends ReactElement<P, Exclude<T, number>> { }
156
157 /**
158 * @deprecated Please use `FunctionComponentElement`
159 */
160 type SFCElement<P> = FunctionComponentElement<P>;
161
162 interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
163 ref?: ('ref' extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
164 }
165
166 type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
167 interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
168 ref?: LegacyRef<T> | undefined;
169 }
170
171 type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
172
173 // string fallback for custom web-components
174 interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element> extends ReactElement<P, string> {
175 ref: LegacyRef<T>;
176 }
177
178 // ReactHTML for ReactHTMLElement
179 interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> { }
180
181 interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
182 type: keyof ReactHTML;
183 }
184
185 // ReactSVG for ReactSVGElement
186 interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
187 type: keyof ReactSVG;
188 }
189
190 interface ReactPortal extends ReactElement {
191 key: Key | null;
192 children: ReactNode;
193 }
194
195 //
196 // Factories
197 // ----------------------------------------------------------------------
198
199 type Factory<P> = (props?: Attributes & P, ...children: ReactNode[]) => ReactElement<P>;
200
201 /**
202 * @deprecated Please use `FunctionComponentFactory`
203 */
204 type SFCFactory<P> = FunctionComponentFactory<P>;
205
206 type FunctionComponentFactory<P> = (props?: Attributes & P, ...children: ReactNode[]) => FunctionComponentElement<P>;
207
208 type ComponentFactory<P, T extends Component<P, ComponentState>> =
209 (props?: ClassAttributes<T> & P, ...children: ReactNode[]) => CElement<P, T>;
210
211 type CFactory<P, T extends Component<P, ComponentState>> = ComponentFactory<P, T>;
212 type ClassicFactory<P> = CFactory<P, ClassicComponent<P, ComponentState>>;
213
214 type DOMFactory<P extends DOMAttributes<T>, T extends Element> =
215 (props?: ClassAttributes<T> & P | null, ...children: ReactNode[]) => DOMElement<P, T>;
216
217 interface HTMLFactory<T extends HTMLElement> extends DetailedHTMLFactory<AllHTMLAttributes<T>, T> {}
218
219 interface DetailedHTMLFactory<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMFactory<P, T> {
220 (props?: ClassAttributes<T> & P | null, ...children: ReactNode[]): DetailedReactHTMLElement<P, T>;
221 }
222
223 interface SVGFactory extends DOMFactory<SVGAttributes<SVGElement>, SVGElement> {
224 (props?: ClassAttributes<SVGElement> & SVGAttributes<SVGElement> | null, ...children: ReactNode[]): ReactSVGElement;
225 }
226
227 //
228 // React Nodes
229 // http://facebook.github.io/react/docs/glossary.html
230 // ----------------------------------------------------------------------
231
232 type ReactText = string | number;
233 type ReactChild = ReactElement | ReactText;
234
235 /**
236 * @deprecated Use either `ReactNode[]` if you need an array or `Iterable<ReactNode>` if its passed to a host component.
237 */
238 interface ReactNodeArray extends ReadonlyArray<ReactNode> {}
239 type ReactFragment = {} | Iterable<ReactNode>;
240 type ReactNode = ReactChild | ReactFragment | ReactPortal | boolean | null | undefined;
241
242 //
243 // Top Level API
244 // ----------------------------------------------------------------------
245
246 // DOM Elements
247 function createFactory<T extends HTMLElement>(
248 type: keyof ReactHTML): HTMLFactory<T>;
249 function createFactory(
250 type: keyof ReactSVG): SVGFactory;
251 function createFactory<P extends DOMAttributes<T>, T extends Element>(
252 type: string): DOMFactory<P, T>;
253
254 // Custom components
255 function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
256 function createFactory<P>(
257 type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P>>): CFactory<P, ClassicComponent<P, ComponentState>>;
258 function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
259 type: ClassType<P, T, C>): CFactory<P, T>;
260 function createFactory<P>(type: ComponentClass<P>): Factory<P>;
261
262 // DOM Elements
263 // TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
264 function createElement(
265 type: "input",
266 props?: InputHTMLAttributes<HTMLInputElement> & ClassAttributes<HTMLInputElement> | null,
267 ...children: ReactNode[]): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
268 function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
269 type: keyof ReactHTML,
270 props?: ClassAttributes<T> & P | null,
271 ...children: ReactNode[]): DetailedReactHTMLElement<P, T>;
272 function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
273 type: keyof ReactSVG,
274 props?: ClassAttributes<T> & P | null,
275 ...children: ReactNode[]): ReactSVGElement;
276 function createElement<P extends DOMAttributes<T>, T extends Element>(
277 type: string,
278 props?: ClassAttributes<T> & P | null,
279 ...children: ReactNode[]): DOMElement<P, T>;
280
281 // Custom components
282
283 function createElement<P extends {}>(
284 type: FunctionComponent<P>,
285 props?: Attributes & P | null,
286 ...children: ReactNode[]): FunctionComponentElement<P>;
287 function createElement<P extends {}>(
288 type: ClassType<P, ClassicComponent<P, ComponentState>, ClassicComponentClass<P>>,
289 props?: ClassAttributes<ClassicComponent<P, ComponentState>> & P | null,
290 ...children: ReactNode[]): CElement<P, ClassicComponent<P, ComponentState>>;
291 function createElement<P extends {}, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
292 type: ClassType<P, T, C>,
293 props?: ClassAttributes<T> & P | null,
294 ...children: ReactNode[]): CElement<P, T>;
295 function createElement<P extends {}>(
296 type: FunctionComponent<P> | ComponentClass<P> | string,
297 props?: Attributes & P | null,
298 ...children: ReactNode[]): ReactElement<P>;
299
300 // DOM Elements
301 // ReactHTMLElement
302 function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
303 element: DetailedReactHTMLElement<P, T>,
304 props?: P,
305 ...children: ReactNode[]): DetailedReactHTMLElement<P, T>;
306 // ReactHTMLElement, less specific
307 function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
308 element: ReactHTMLElement<T>,
309 props?: P,
310 ...children: ReactNode[]): ReactHTMLElement<T>;
311 // SVGElement
312 function cloneElement<P extends SVGAttributes<T>, T extends SVGElement>(
313 element: ReactSVGElement,
314 props?: P,
315 ...children: ReactNode[]): ReactSVGElement;
316 // DOM Element (has to be the last, because type checking stops at first overload that fits)
317 function cloneElement<P extends DOMAttributes<T>, T extends Element>(
318 element: DOMElement<P, T>,
319 props?: DOMAttributes<T> & P,
320 ...children: ReactNode[]): DOMElement<P, T>;
321
322 // Custom components
323 function cloneElement<P>(
324 element: FunctionComponentElement<P>,
325 props?: Partial<P> & Attributes,
326 ...children: ReactNode[]): FunctionComponentElement<P>;
327 function cloneElement<P, T extends Component<P, ComponentState>>(
328 element: CElement<P, T>,
329 props?: Partial<P> & ClassAttributes<T>,
330 ...children: ReactNode[]): CElement<P, T>;
331 function cloneElement<P>(
332 element: ReactElement<P>,
333 props?: Partial<P> & Attributes,
334 ...children: ReactNode[]): ReactElement<P>;
335
336 // Context via RenderProps
337 interface ProviderProps<T> {
338 value: T;
339 children?: ReactNode | undefined;
340 }
341
342 interface ConsumerProps<T> {
343 children: (value: T) => ReactNode;
344 }
345
346 // TODO: similar to how Fragment is actually a symbol, the values returned from createContext,
347 // forwardRef and memo are actually objects that are treated specially by the renderer; see:
348 // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/ReactContext.js#L35-L48
349 // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/forwardRef.js#L42-L45
350 // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/memo.js#L27-L31
351 // However, we have no way of telling the JSX parser that it's a JSX element type or its props other than
352 // by pretending to be a normal component.
353 //
354 // We don't just use ComponentType or FunctionComponent types because you are not supposed to attach statics to this
355 // object, but rather to the original function.
356 interface ExoticComponent<P = {}> {
357 /**
358 * **NOTE**: Exotic components are not callable.
359 */
360 (props: P): (ReactElement|null);
361 readonly $$typeof: symbol;
362 }
363
364 interface NamedExoticComponent<P = {}> extends ExoticComponent<P> {
365 displayName?: string | undefined;
366 }
367
368 interface ProviderExoticComponent<P> extends ExoticComponent<P> {
369 propTypes?: WeakValidationMap<P> | undefined;
370 }
371
372 type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
373
374 // NOTE: only the Context object itself can get a displayName
375 // https://github.com/facebook/react-devtools/blob/e0b854e4c/backend/attachRendererFiber.js#L310-L325
376 type Provider<T> = ProviderExoticComponent<ProviderProps<T>>;
377 type Consumer<T> = ExoticComponent<ConsumerProps<T>>;
378 interface Context<T> {
379 Provider: Provider<T>;
380 Consumer: Consumer<T>;
381 displayName?: string | undefined;
382 }
383 function createContext<T>(
384 // If you thought this should be optional, see
385 // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106
386 defaultValue: T,
387 ): Context<T>;
388
389 function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
390
391 const Children: ReactChildren;
392 const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
393 const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;
394
395 interface SuspenseProps {
396 children?: ReactNode | undefined;
397
398 /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
399 fallback: NonNullable<ReactNode>|null;
400 }
401 /**
402 * This feature is not yet available for server-side rendering.
403 * Suspense support will be added in a later release.
404 */
405 const Suspense: ExoticComponent<SuspenseProps>;
406 const version: string;
407
408 /**
409 * {@link https://reactjs.org/docs/profiler.html#onrender-callback Profiler API}
410 */
411 type ProfilerOnRenderCallback = (
412 id: string,
413 phase: "mount" | "update",
414 actualDuration: number,
415 baseDuration: number,
416 startTime: number,
417 commitTime: number,
418 interactions: Set<SchedulerInteraction>,
419 ) => void;
420 interface ProfilerProps {
421 children?: ReactNode | undefined;
422 id: string;
423 onRender: ProfilerOnRenderCallback;
424 }
425
426 const Profiler: ExoticComponent<ProfilerProps>;
427
428 //
429 // Component API
430 // ----------------------------------------------------------------------
431
432 type ReactInstance = Component<any> | Element;
433
434 // Base component for plain JS classes
435 interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> { }
436 class Component<P, S> {
437 // tslint won't let me format the sample code in a way that vscode likes it :(
438 /**
439 * If set, `this.context` will be set at runtime to the current value of the given Context.
440 *
441 * Usage:
442 *
443 * ```ts
444 * type MyContext = number
445 * const Ctx = React.createContext<MyContext>(0)
446 *
447 * class Foo extends React.Component {
448 * static contextType = Ctx
449 * context!: React.ContextType<typeof Ctx>
450 * render () {
451 * return <>My context's value: {this.context}</>;
452 * }
453 * }
454 * ```
455 *
456 * @see https://reactjs.org/docs/context.html#classcontexttype
457 */
458 static contextType?: Context<any> | undefined;
459
460 /**
461 * If using the new style context, re-declare this in your class to be the
462 * `React.ContextType` of your `static contextType`.
463 * Should be used with type annotation or static contextType.
464 *
465 * ```ts
466 * static contextType = MyContext
467 * // For TS pre-3.7:
468 * context!: React.ContextType<typeof MyContext>
469 * // For TS 3.7 and above:
470 * declare context: React.ContextType<typeof MyContext>
471 * ```
472 *
473 * @see https://reactjs.org/docs/context.html
474 */
475 // TODO (TypeScript 3.0): unknown
476 context: any;
477
478 constructor(props: Readonly<P> | P);
479 /**
480 * @deprecated
481 * @see https://reactjs.org/docs/legacy-context.html
482 */
483 constructor(props: P, context: any);
484
485 // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
486 // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
487 // Also, the ` | S` allows intellisense to not be dumbisense
488 setState<K extends keyof S>(
489 state: ((prevState: Readonly<S>, props: Readonly<P>) => (Pick<S, K> | S | null)) | (Pick<S, K> | S | null),
490 callback?: () => void
491 ): void;
492
493 forceUpdate(callback?: () => void): void;
494 render(): ReactNode;
495
496 // React.Props<T> is now deprecated, which means that the `children`
497 // property is not available on `P` by default, even though you can
498 // always pass children as variadic arguments to `createElement`.
499 // In the future, if we can define its call signature conditionally
500 // on the existence of `children` in `P`, then we should remove this.
501 readonly props: Readonly<P> & Readonly<{ children?: ReactNode | undefined }>;
502 state: Readonly<S>;
503 /**
504 * @deprecated
505 * https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs
506 */
507 refs: {
508 [key: string]: ReactInstance
509 };
510 }
511
512 class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> { }
513
514 interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
515 replaceState(nextState: S, callback?: () => void): void;
516 isMounted(): boolean;
517 getInitialState?(): S;
518 }
519
520 interface ChildContextProvider<CC> {
521 getChildContext(): CC;
522 }
523
524 //
525 // Class Interfaces
526 // ----------------------------------------------------------------------
527
528 /**
529 * @deprecated as of recent React versions, function components can no
530 * longer be considered 'stateless'. Please use `FunctionComponent` instead.
531 *
532 * @see [React Hooks](https://reactjs.org/docs/hooks-intro.html)
533 */
534 type SFC<P = {}> = FunctionComponent<P>;
535
536 /**
537 * @deprecated as of recent React versions, function components can no
538 * longer be considered 'stateless'. Please use `FunctionComponent` instead.
539 *
540 * @see [React Hooks](https://reactjs.org/docs/hooks-intro.html)
541 */
542 type StatelessComponent<P = {}> = FunctionComponent<P>;
543
544 type FC<P = {}> = FunctionComponent<P>;
545
546 interface FunctionComponent<P = {}> {
547 (props: PropsWithChildren<P>, context?: any): ReactElement<any, any> | null;
548 propTypes?: WeakValidationMap<P> | undefined;
549 contextTypes?: ValidationMap<any> | undefined;
550 defaultProps?: Partial<P> | undefined;
551 displayName?: string | undefined;
552 }
553
554 type VFC<P = {}> = VoidFunctionComponent<P>;
555
556 interface VoidFunctionComponent<P = {}> {
557 (props: P, context?: any): ReactElement<any, any> | null;
558 propTypes?: WeakValidationMap<P> | undefined;
559 contextTypes?: ValidationMap<any> | undefined;
560 defaultProps?: Partial<P> | undefined;
561 displayName?: string | undefined;
562 }
563
564 type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
565
566 interface ForwardRefRenderFunction<T, P = {}> {
567 (props: PropsWithChildren<P>, ref: ForwardedRef<T>): ReactElement | null;
568 displayName?: string | undefined;
569 // explicit rejected with `never` required due to
570 // https://github.com/microsoft/TypeScript/issues/36826
571 /**
572 * defaultProps are not supported on render functions
573 */
574 defaultProps?: never | undefined;
575 /**
576 * propTypes are not supported on render functions
577 */
578 propTypes?: never | undefined;
579 }
580
581 /**
582 * @deprecated Use ForwardRefRenderFunction. forwardRef doesn't accept a
583 * "real" component.
584 */
585 interface RefForwardingComponent <T, P = {}> extends ForwardRefRenderFunction<T, P> {}
586
587 interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
588 new (props: P, context?: any): Component<P, S>;
589 propTypes?: WeakValidationMap<P> | undefined;
590 contextType?: Context<any> | undefined;
591 contextTypes?: ValidationMap<any> | undefined;
592 childContextTypes?: ValidationMap<any> | undefined;
593 defaultProps?: Partial<P> | undefined;
594 displayName?: string | undefined;
595 }
596
597 interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
598 new (props: P, context?: any): ClassicComponent<P, ComponentState>;
599 getDefaultProps?(): P;
600 }
601
602 /**
603 * We use an intersection type to infer multiple type parameters from
604 * a single argument, which is useful for many top-level API defs.
605 * See https://github.com/Microsoft/TypeScript/issues/7234 for more info.
606 */
607 type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
608 C &
609 (new (props: P, context?: any) => T);
610
611 //
612 // Component Specs and Lifecycle
613 // ----------------------------------------------------------------------
614
615 // This should actually be something like `Lifecycle<P, S> | DeprecatedLifecycle<P, S>`,
616 // as React will _not_ call the deprecated lifecycle methods if any of the new lifecycle
617 // methods are present.
618 interface ComponentLifecycle<P, S, SS = any> extends NewLifecycle<P, S, SS>, DeprecatedLifecycle<P, S> {
619 /**
620 * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
621 */
622 componentDidMount?(): void;
623 /**
624 * Called to determine whether the change in props and state should trigger a re-render.
625 *
626 * `Component` always returns true.
627 * `PureComponent` implements a shallow comparison on props and state and returns true if any
628 * props or states have changed.
629 *
630 * If false is returned, `Component#render`, `componentWillUpdate`
631 * and `componentDidUpdate` will not be called.
632 */
633 shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): boolean;
634 /**
635 * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
636 * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
637 */
638 componentWillUnmount?(): void;
639 /**
640 * Catches exceptions generated in descendant components. Unhandled exceptions will cause
641 * the entire component tree to unmount.
642 */
643 componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;
644 }
645
646 // Unfortunately, we have no way of declaring that the component constructor must implement this
647 interface StaticLifecycle<P, S> {
648 getDerivedStateFromProps?: GetDerivedStateFromProps<P, S> | undefined;
649 getDerivedStateFromError?: GetDerivedStateFromError<P, S> | undefined;
650 }
651
652 type GetDerivedStateFromProps<P, S> =
653 /**
654 * Returns an update to a component's state based on its new props and old state.
655 *
656 * Note: its presence prevents any of the deprecated lifecycle methods from being invoked
657 */
658 (nextProps: Readonly<P>, prevState: S) => Partial<S> | null;
659
660 type GetDerivedStateFromError<P, S> =
661 /**
662 * This lifecycle is invoked after an error has been thrown by a descendant component.
663 * It receives the error that was thrown as a parameter and should return a value to update state.
664 *
665 * Note: its presence prevents any of the deprecated lifecycle methods from being invoked
666 */
667 (error: any) => Partial<S> | null;
668
669 // This should be "infer SS" but can't use it yet
670 interface NewLifecycle<P, S, SS> {
671 /**
672 * Runs before React applies the result of `render` to the document, and
673 * returns an object to be given to componentDidUpdate. Useful for saving
674 * things such as scroll position before `render` causes changes to it.
675 *
676 * Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated
677 * lifecycle events from running.
678 */
679 getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null;
680 /**
681 * Called immediately after updating occurs. Not called for the initial render.
682 *
683 * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.
684 */
685 componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void;
686 }
687
688 interface DeprecatedLifecycle<P, S> {
689 /**
690 * Called immediately before mounting occurs, and before `Component#render`.
691 * Avoid introducing any side-effects or subscriptions in this method.
692 *
693 * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps
694 * prevents this from being invoked.
695 *
696 * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17
697 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state
698 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
699 */
700 componentWillMount?(): void;
701 /**
702 * Called immediately before mounting occurs, and before `Component#render`.
703 * Avoid introducing any side-effects or subscriptions in this method.
704 *
705 * This method will not stop working in React 17.
706 *
707 * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps
708 * prevents this from being invoked.
709 *
710 * @deprecated 16.3, use componentDidMount or the constructor instead
711 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state
712 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
713 */
714 UNSAFE_componentWillMount?(): void;
715 /**
716 * Called when the component may be receiving new props.
717 * React may call this even if props have not changed, so be sure to compare new and existing
718 * props if you only want to handle changes.
719 *
720 * Calling `Component#setState` generally does not trigger this method.
721 *
722 * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps
723 * prevents this from being invoked.
724 *
725 * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17
726 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props
727 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
728 */
729 componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
730 /**
731 * Called when the component may be receiving new props.
732 * React may call this even if props have not changed, so be sure to compare new and existing
733 * props if you only want to handle changes.
734 *
735 * Calling `Component#setState` generally does not trigger this method.
736 *
737 * This method will not stop working in React 17.
738 *
739 * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps
740 * prevents this from being invoked.
741 *
742 * @deprecated 16.3, use static getDerivedStateFromProps instead
743 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props
744 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
745 */
746 UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void;
747 /**
748 * Called immediately before rendering when new props or state is received. Not called for the initial render.
749 *
750 * Note: You cannot call `Component#setState` here.
751 *
752 * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps
753 * prevents this from being invoked.
754 *
755 * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17
756 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update
757 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
758 */
759 componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
760 /**
761 * Called immediately before rendering when new props or state is received. Not called for the initial render.
762 *
763 * Note: You cannot call `Component#setState` here.
764 *
765 * This method will not stop working in React 17.
766 *
767 * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps
768 * prevents this from being invoked.
769 *
770 * @deprecated 16.3, use getSnapshotBeforeUpdate instead
771 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update
772 * @see https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path
773 */
774 UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
775 }
776
777 interface Mixin<P, S> extends ComponentLifecycle<P, S> {
778 mixins?: Array<Mixin<P, S>> | undefined;
779 statics?: {
780 [key: string]: any;
781 } | undefined;
782
783 displayName?: string | undefined;
784 propTypes?: ValidationMap<any> | undefined;
785 contextTypes?: ValidationMap<any> | undefined;
786 childContextTypes?: ValidationMap<any> | undefined;
787
788 getDefaultProps?(): P;
789 getInitialState?(): S;
790 }
791
792 interface ComponentSpec<P, S> extends Mixin<P, S> {
793 render(): ReactNode;
794
795 [propertyName: string]: any;
796 }
797
798 function createRef<T>(): RefObject<T>;
799
800 // will show `ForwardRef(${Component.displayName || Component.name})` in devtools by default,
801 // but can be given its own specific name
802 interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
803 defaultProps?: Partial<P> | undefined;
804 propTypes?: WeakValidationMap<P> | undefined;
805 }
806
807 function forwardRef<T, P = {}>(render: ForwardRefRenderFunction<T, P>): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
808
809 /** Ensures that the props do not include ref at all */
810 type PropsWithoutRef<P> =
811 // Pick would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
812 // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
813 // https://github.com/Microsoft/TypeScript/issues/28339
814 P extends any ? ('ref' extends keyof P ? Pick<P, Exclude<keyof P, 'ref'>> : P) : P;
815 /** Ensures that the props do not include string ref, which cannot be forwarded */
816 type PropsWithRef<P> =
817 // Just "P extends { ref?: infer R }" looks sufficient, but R will infer as {} if P is {}.
818 'ref' extends keyof P
819 ? P extends { ref?: infer R | undefined }
820 ? string extends R
821 ? PropsWithoutRef<P> & { ref?: Exclude<R, string> | undefined }
822 : P
823 : P
824 : P;
825
826 type PropsWithChildren<P> = P & { children?: ReactNode | undefined };
827
828 /**
829 * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,
830 * or ComponentPropsWithoutRef when refs are not supported.
831 */
832 type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> =
833 T extends JSXElementConstructor<infer P>
834 ? P
835 : T extends keyof JSX.IntrinsicElements
836 ? JSX.IntrinsicElements[T]
837 : {};
838 type ComponentPropsWithRef<T extends ElementType> =
839 T extends ComponentClass<infer P>
840 ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
841 : PropsWithRef<ComponentProps<T>>;
842 type ComponentPropsWithoutRef<T extends ElementType> =
843 PropsWithoutRef<ComponentProps<T>>;
844
845 type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
846 ComponentPropsWithoutRef<T> & RefAttributes<infer Method>
847 >
848 ? Method
849 : ComponentPropsWithRef<T> extends RefAttributes<infer Method>
850 ? Method
851 : never;
852
853 // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
854 // but can be given its own specific name
855 type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<ComponentPropsWithRef<T>> & {
856 readonly type: T;
857 };
858
859 function memo<P extends object>(
860 Component: FunctionComponent<P>,
861 propsAreEqual?: (prevProps: Readonly<PropsWithChildren<P>>, nextProps: Readonly<PropsWithChildren<P>>) => boolean
862 ): NamedExoticComponent<P>;
863 function memo<T extends ComponentType<any>>(
864 Component: T,
865 propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean
866 ): MemoExoticComponent<T>;
867
868 type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
869 readonly _result: T;
870 };
871
872 function lazy<T extends ComponentType<any>>(
873 factory: () => Promise<{ default: T }>
874 ): LazyExoticComponent<T>;
875
876 //
877 // React Hooks
878 // ----------------------------------------------------------------------
879
880 // based on the code in https://github.com/facebook/react/pull/13968
881
882 // Unlike the class component setState, the updates are not allowed to be partial
883 type SetStateAction<S> = S | ((prevState: S) => S);
884 // this technically does accept a second argument, but it's already under a deprecation warning
885 // and it's not even released so probably better to not define it.
886 type Dispatch<A> = (value: A) => void;
887 // Since action _can_ be undefined, dispatch may be called without any parameters.
888 type DispatchWithoutAction = () => void;
889 // Unlike redux, the actions _can_ be anything
890 type Reducer<S, A> = (prevState: S, action: A) => S;
891 // If useReducer accepts a reducer without action, dispatch may be called without any parameters.
892 type ReducerWithoutAction<S> = (prevState: S) => S;
893 // types used to try and prevent the compiler from reducing S
894 // to a supertype common with the second argument to useReducer()
895 type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
896 type ReducerAction<R extends Reducer<any, any>> = R extends Reducer<any, infer A> ? A : never;
897 // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===
898 type ReducerStateWithoutAction<R extends ReducerWithoutAction<any>> =
899 R extends ReducerWithoutAction<infer S> ? S : never;
900 // TODO (TypeScript 3.0): ReadonlyArray<unknown>
901 type DependencyList = ReadonlyArray<any>;
902
903 // NOTE: callbacks are _only_ allowed to return either void, or a destructor.
904 type EffectCallback = () => (void | Destructor);
905
906 interface MutableRefObject<T> {
907 current: T;
908 }
909
910 // This will technically work if you give a Consumer<T> or Provider<T> but it's deprecated and warns
911 /**
912 * Accepts a context object (the value returned from `React.createContext`) and returns the current
913 * context value, as given by the nearest context provider for the given context.
914 *
915 * @version 16.8.0
916 * @see https://reactjs.org/docs/hooks-reference.html#usecontext
917 */
918 function useContext<T>(context: Context<T>/*, (not public API) observedBits?: number|boolean */): T;
919 /**
920 * Returns a stateful value, and a function to update it.
921 *
922 * @version 16.8.0
923 * @see https://reactjs.org/docs/hooks-reference.html#usestate
924 */
925 function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
926 // convenience overload when first argument is omitted
927 /**
928 * Returns a stateful value, and a function to update it.
929 *
930 * @version 16.8.0
931 * @see https://reactjs.org/docs/hooks-reference.html#usestate
932 */
933 function useState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
934 /**
935 * An alternative to `useState`.
936 *
937 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
938 * multiple sub-values. It also lets you optimize performance for components that trigger deep
939 * updates because you can pass `dispatch` down instead of callbacks.
940 *
941 * @version 16.8.0
942 * @see https://reactjs.org/docs/hooks-reference.html#usereducer
943 */
944 // overload where dispatch could accept 0 arguments.
945 function useReducer<R extends ReducerWithoutAction<any>, I>(
946 reducer: R,
947 initializerArg: I,
948 initializer: (arg: I) => ReducerStateWithoutAction<R>
949 ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
950 /**
951 * An alternative to `useState`.
952 *
953 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
954 * multiple sub-values. It also lets you optimize performance for components that trigger deep
955 * updates because you can pass `dispatch` down instead of callbacks.
956 *
957 * @version 16.8.0
958 * @see https://reactjs.org/docs/hooks-reference.html#usereducer
959 */
960 // overload where dispatch could accept 0 arguments.
961 function useReducer<R extends ReducerWithoutAction<any>>(
962 reducer: R,
963 initializerArg: ReducerStateWithoutAction<R>,
964 initializer?: undefined
965 ): [ReducerStateWithoutAction<R>, DispatchWithoutAction];
966 /**
967 * An alternative to `useState`.
968 *
969 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
970 * multiple sub-values. It also lets you optimize performance for components that trigger deep
971 * updates because you can pass `dispatch` down instead of callbacks.
972 *
973 * @version 16.8.0
974 * @see https://reactjs.org/docs/hooks-reference.html#usereducer
975 */
976 // overload where "I" may be a subset of ReducerState<R>; used to provide autocompletion.
977 // If "I" matches ReducerState<R> exactly then the last overload will allow initializer to be omitted.
978 // the last overload effectively behaves as if the identity function (x => x) is the initializer.
979 function useReducer<R extends Reducer<any, any>, I>(
980 reducer: R,
981 initializerArg: I & ReducerState<R>,
982 initializer: (arg: I & ReducerState<R>) => ReducerState<R>
983 ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
984 /**
985 * An alternative to `useState`.
986 *
987 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
988 * multiple sub-values. It also lets you optimize performance for components that trigger deep
989 * updates because you can pass `dispatch` down instead of callbacks.
990 *
991 * @version 16.8.0
992 * @see https://reactjs.org/docs/hooks-reference.html#usereducer
993 */
994 // overload for free "I"; all goes as long as initializer converts it into "ReducerState<R>".
995 function useReducer<R extends Reducer<any, any>, I>(
996 reducer: R,
997 initializerArg: I,
998 initializer: (arg: I) => ReducerState<R>
999 ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1000 /**
1001 * An alternative to `useState`.
1002 *
1003 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1004 * multiple sub-values. It also lets you optimize performance for components that trigger deep
1005 * updates because you can pass `dispatch` down instead of callbacks.
1006 *
1007 * @version 16.8.0
1008 * @see https://reactjs.org/docs/hooks-reference.html#usereducer
1009 */
1010
1011 // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.
1012 // The Flow types do have an overload for 3-ary invocation with undefined initializer.
1013
1014 // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common
1015 // supertype between the reducer's return type and the initialState (or the initializer's return type),
1016 // which would prevent autocompletion from ever working.
1017
1018 // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug
1019 // in older versions, or a regression in newer versions of the typescript completion service.
1020 function useReducer<R extends Reducer<any, any>>(
1021 reducer: R,
1022 initialState: ReducerState<R>,
1023 initializer?: undefined
1024 ): [ReducerState<R>, Dispatch<ReducerAction<R>>];
1025 /**
1026 * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1027 * (`initialValue`). The returned object will persist for the full lifetime of the component.
1028 *
1029 * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1030 * value around similar to how you’d use instance fields in classes.
1031 *
1032 * @version 16.8.0
1033 * @see https://reactjs.org/docs/hooks-reference.html#useref
1034 */
1035 function useRef<T>(initialValue: T): MutableRefObject<T>;
1036 // convenience overload for refs given as a ref prop as they typically start with a null value
1037 /**
1038 * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1039 * (`initialValue`). The returned object will persist for the full lifetime of the component.
1040 *
1041 * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1042 * value around similar to how you’d use instance fields in classes.
1043 *
1044 * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type
1045 * of the generic argument.
1046 *
1047 * @version 16.8.0
1048 * @see https://reactjs.org/docs/hooks-reference.html#useref
1049 */
1050 function useRef<T>(initialValue: T|null): RefObject<T>;
1051 // convenience overload for potentially undefined initialValue / call with 0 arguments
1052 // has a default to stop it from defaulting to {} instead
1053 /**
1054 * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1055 * (`initialValue`). The returned object will persist for the full lifetime of the component.
1056 *
1057 * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1058 * value around similar to how you’d use instance fields in classes.
1059 *
1060 * @version 16.8.0
1061 * @see https://reactjs.org/docs/hooks-reference.html#useref
1062 */
1063 function useRef<T = undefined>(): MutableRefObject<T | undefined>;
1064 /**
1065 * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
1066 * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
1067 * `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint.
1068 *
1069 * Prefer the standard `useEffect` when possible to avoid blocking visual updates.
1070 *
1071 * If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as
1072 * `componentDidMount` and `componentDidUpdate`.
1073 *
1074 * @version 16.8.0
1075 * @see https://reactjs.org/docs/hooks-reference.html#uselayouteffect
1076 */
1077 function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;
1078 /**
1079 * Accepts a function that contains imperative, possibly effectful code.
1080 *
1081 * @param effect Imperative function that can return a cleanup function
1082 * @param deps If present, effect will only activate if the values in the list change.
1083 *
1084 * @version 16.8.0
1085 * @see https://reactjs.org/docs/hooks-reference.html#useeffect
1086 */
1087 function useEffect(effect: EffectCallback, deps?: DependencyList): void;
1088 // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref<T>
1089 /**
1090 * `useImperativeHandle` customizes the instance value that is exposed to parent components when using
1091 * `ref`. As always, imperative code using refs should be avoided in most cases.
1092 *
1093 * `useImperativeHandle` should be used with `React.forwardRef`.
1094 *
1095 * @version 16.8.0
1096 * @see https://reactjs.org/docs/hooks-reference.html#useimperativehandle
1097 */
1098 function useImperativeHandle<T, R extends T>(ref: Ref<T>|undefined, init: () => R, deps?: DependencyList): void;
1099 // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key
1100 // useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y.
1101 /**
1102 * `useCallback` will return a memoized version of the callback that only changes if one of the `inputs`
1103 * has changed.
1104 *
1105 * @version 16.8.0
1106 * @see https://reactjs.org/docs/hooks-reference.html#usecallback
1107 */
1108 // TODO (TypeScript 3.0): <T extends (...args: never[]) => unknown>
1109 function useCallback<T extends (...args: any[]) => any>(callback: T, deps: DependencyList): T;
1110 /**
1111 * `useMemo` will only recompute the memoized value when one of the `deps` has changed.
1112 *
1113 * Usage note: if calling `useMemo` with a referentially stable function, also give it as the input in
1114 * the second argument.
1115 *
1116 * ```ts
1117 * function expensive () { ... }
1118 *
1119 * function Component () {
1120 * const expensiveResult = useMemo(expensive, [expensive])
1121 * return ...
1122 * }
1123 * ```
1124 *
1125 * @version 16.8.0
1126 * @see https://reactjs.org/docs/hooks-reference.html#usememo
1127 */
1128 // allow undefined, but don't make it optional as that is very likely a mistake
1129 function useMemo<T>(factory: () => T, deps: DependencyList | undefined): T;
1130 /**
1131 * `useDebugValue` can be used to display a label for custom hooks in React DevTools.
1132 *
1133 * NOTE: We don’t recommend adding debug values to every custom hook.
1134 * It’s most valuable for custom hooks that are part of shared libraries.
1135 *
1136 * @version 16.8.0
1137 * @see https://reactjs.org/docs/hooks-reference.html#usedebugvalue
1138 */
1139 // the name of the custom hook is itself derived from the function name at runtime:
1140 // it's just the function name without the "use" prefix.
1141 function useDebugValue<T>(value: T, format?: (value: T) => any): void;
1142
1143 //
1144 // Event System
1145 // ----------------------------------------------------------------------
1146 // TODO: change any to unknown when moving to TS v3
1147 interface BaseSyntheticEvent<E = object, C = any, T = any> {
1148 nativeEvent: E;
1149 currentTarget: C;
1150 target: T;
1151 bubbles: boolean;
1152 cancelable: boolean;
1153 defaultPrevented: boolean;
1154 eventPhase: number;
1155 isTrusted: boolean;
1156 preventDefault(): void;
1157 isDefaultPrevented(): boolean;
1158 stopPropagation(): void;
1159 isPropagationStopped(): boolean;
1160 persist(): void;
1161 timeStamp: number;
1162 type: string;
1163 }
1164
1165 /**
1166 * currentTarget - a reference to the element on which the event listener is registered.
1167 *
1168 * target - a reference to the element from which the event was originally dispatched.
1169 * This might be a child element to the element on which the event listener is registered.
1170 * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
1171 */
1172 interface SyntheticEvent<T = Element, E = Event> extends BaseSyntheticEvent<E, EventTarget & T, EventTarget> {}
1173
1174 interface ClipboardEvent<T = Element> extends SyntheticEvent<T, NativeClipboardEvent> {
1175 clipboardData: DataTransfer;
1176 }
1177
1178 interface CompositionEvent<T = Element> extends SyntheticEvent<T, NativeCompositionEvent> {
1179 data: string;
1180 }
1181
1182 interface DragEvent<T = Element> extends MouseEvent<T, NativeDragEvent> {
1183 dataTransfer: DataTransfer;
1184 }
1185
1186 interface PointerEvent<T = Element> extends MouseEvent<T, NativePointerEvent> {
1187 pointerId: number;
1188 pressure: number;
1189 tangentialPressure: number;
1190 tiltX: number;
1191 tiltY: number;
1192 twist: number;
1193 width: number;
1194 height: number;
1195 pointerType: 'mouse' | 'pen' | 'touch';
1196 isPrimary: boolean;
1197 }
1198
1199 interface FocusEvent<Target = Element, RelatedTarget = Element> extends SyntheticEvent<Target, NativeFocusEvent> {
1200 relatedTarget: (EventTarget & RelatedTarget) | null;
1201 target: EventTarget & Target;
1202 }
1203
1204 interface FormEvent<T = Element> extends SyntheticEvent<T> {
1205 }
1206
1207 interface InvalidEvent<T = Element> extends SyntheticEvent<T> {
1208 target: EventTarget & T;
1209 }
1210
1211 interface ChangeEvent<T = Element> extends SyntheticEvent<T> {
1212 target: EventTarget & T;
1213 }
1214
1215 interface KeyboardEvent<T = Element> extends SyntheticEvent<T, NativeKeyboardEvent> {
1216 altKey: boolean;
1217 /** @deprecated */
1218 charCode: number;
1219 ctrlKey: boolean;
1220 code: string;
1221 /**
1222 * 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.
1223 */
1224 getModifierState(key: string): boolean;
1225 /**
1226 * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values
1227 */
1228 key: string;
1229 /** @deprecated */
1230 keyCode: number;
1231 locale: string;
1232 location: number;
1233 metaKey: boolean;
1234 repeat: boolean;
1235 shiftKey: boolean;
1236 /** @deprecated */
1237 which: number;
1238 }
1239
1240 interface MouseEvent<T = Element, E = NativeMouseEvent> extends UIEvent<T, E> {
1241 altKey: boolean;
1242 button: number;
1243 buttons: number;
1244 clientX: number;
1245 clientY: number;
1246 ctrlKey: boolean;
1247 /**
1248 * 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.
1249 */
1250 getModifierState(key: string): boolean;
1251 metaKey: boolean;
1252 movementX: number;
1253 movementY: number;
1254 pageX: number;
1255 pageY: number;
1256 relatedTarget: EventTarget | null;
1257 screenX: number;
1258 screenY: number;
1259 shiftKey: boolean;
1260 }
1261
1262 interface TouchEvent<T = Element> extends UIEvent<T, NativeTouchEvent> {
1263 altKey: boolean;
1264 changedTouches: TouchList;
1265 ctrlKey: boolean;
1266 /**
1267 * 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.
1268 */
1269 getModifierState(key: string): boolean;
1270 metaKey: boolean;
1271 shiftKey: boolean;
1272 targetTouches: TouchList;
1273 touches: TouchList;
1274 }
1275
1276 interface UIEvent<T = Element, E = NativeUIEvent> extends SyntheticEvent<T, E> {
1277 detail: number;
1278 view: AbstractView;
1279 }
1280
1281 interface WheelEvent<T = Element> extends MouseEvent<T, NativeWheelEvent> {
1282 deltaMode: number;
1283 deltaX: number;
1284 deltaY: number;
1285 deltaZ: number;
1286 }
1287
1288 interface AnimationEvent<T = Element> extends SyntheticEvent<T, NativeAnimationEvent> {
1289 animationName: string;
1290 elapsedTime: number;
1291 pseudoElement: string;
1292 }
1293
1294 interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
1295 elapsedTime: number;
1296 propertyName: string;
1297 pseudoElement: string;
1298 }
1299
1300 //
1301 // Event Handler Types
1302 // ----------------------------------------------------------------------
1303
1304 type EventHandler<E extends SyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"];
1305
1306 type ReactEventHandler<T = Element> = EventHandler<SyntheticEvent<T>>;
1307
1308 type ClipboardEventHandler<T = Element> = EventHandler<ClipboardEvent<T>>;
1309 type CompositionEventHandler<T = Element> = EventHandler<CompositionEvent<T>>;
1310 type DragEventHandler<T = Element> = EventHandler<DragEvent<T>>;
1311 type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
1312 type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
1313 type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
1314 type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
1315 type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
1316 type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
1317 type PointerEventHandler<T = Element> = EventHandler<PointerEvent<T>>;
1318 type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
1319 type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
1320 type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
1321 type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
1322
1323 //
1324 // Props / DOM Attributes
1325 // ----------------------------------------------------------------------
1326
1327 /**
1328 * @deprecated. This was used to allow clients to pass `ref` and `key`
1329 * to `createElement`, which is no longer necessary due to intersection
1330 * types. If you need to declare a props object before passing it to
1331 * `createElement` or a factory, use `ClassAttributes<T>`:
1332 *
1333 * ```ts
1334 * var b: Button | null;
1335 * var props: ButtonProps & ClassAttributes<Button> = {
1336 * ref: b => button = b, // ok!
1337 * label: "I'm a Button"
1338 * };
1339 * ```
1340 */
1341 interface Props<T> {
1342 children?: ReactNode | undefined;
1343 key?: Key | undefined;
1344 ref?: LegacyRef<T> | undefined;
1345 }
1346
1347 interface HTMLProps<T> extends AllHTMLAttributes<T>, ClassAttributes<T> {
1348 }
1349
1350 type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = ClassAttributes<T> & E;
1351
1352 interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
1353 }
1354
1355 interface DOMAttributes<T> {
1356 children?: ReactNode | undefined;
1357 dangerouslySetInnerHTML?: {
1358 __html: string;
1359 } | undefined;
1360
1361 // Clipboard Events
1362 onCopy?: ClipboardEventHandler<T> | undefined;
1363 onCopyCapture?: ClipboardEventHandler<T> | undefined;
1364 onCut?: ClipboardEventHandler<T> | undefined;
1365 onCutCapture?: ClipboardEventHandler<T> | undefined;
1366 onPaste?: ClipboardEventHandler<T> | undefined;
1367 onPasteCapture?: ClipboardEventHandler<T> | undefined;
1368
1369 // Composition Events
1370 onCompositionEnd?: CompositionEventHandler<T> | undefined;
1371 onCompositionEndCapture?: CompositionEventHandler<T> | undefined;
1372 onCompositionStart?: CompositionEventHandler<T> | undefined;
1373 onCompositionStartCapture?: CompositionEventHandler<T> | undefined;
1374 onCompositionUpdate?: CompositionEventHandler<T> | undefined;
1375 onCompositionUpdateCapture?: CompositionEventHandler<T> | undefined;
1376
1377 // Focus Events
1378 onFocus?: FocusEventHandler<T> | undefined;
1379 onFocusCapture?: FocusEventHandler<T> | undefined;
1380 onBlur?: FocusEventHandler<T> | undefined;
1381 onBlurCapture?: FocusEventHandler<T> | undefined;
1382
1383 // Form Events
1384 onChange?: FormEventHandler<T> | undefined;
1385 onChangeCapture?: FormEventHandler<T> | undefined;
1386 onBeforeInput?: FormEventHandler<T> | undefined;
1387 onBeforeInputCapture?: FormEventHandler<T> | undefined;
1388 onInput?: FormEventHandler<T> | undefined;
1389 onInputCapture?: FormEventHandler<T> | undefined;
1390 onReset?: FormEventHandler<T> | undefined;
1391 onResetCapture?: FormEventHandler<T> | undefined;
1392 onSubmit?: FormEventHandler<T> | undefined;
1393 onSubmitCapture?: FormEventHandler<T> | undefined;
1394 onInvalid?: FormEventHandler<T> | undefined;
1395 onInvalidCapture?: FormEventHandler<T> | undefined;
1396
1397 // Image Events
1398 onLoad?: ReactEventHandler<T> | undefined;
1399 onLoadCapture?: ReactEventHandler<T> | undefined;
1400 onError?: ReactEventHandler<T> | undefined; // also a Media Event
1401 onErrorCapture?: ReactEventHandler<T> | undefined; // also a Media Event
1402
1403 // Keyboard Events
1404 onKeyDown?: KeyboardEventHandler<T> | undefined;
1405 onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
1406 onKeyPress?: KeyboardEventHandler<T> | undefined;
1407 onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
1408 onKeyUp?: KeyboardEventHandler<T> | undefined;
1409 onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
1410
1411 // Media Events
1412 onAbort?: ReactEventHandler<T> | undefined;
1413 onAbortCapture?: ReactEventHandler<T> | undefined;
1414 onCanPlay?: ReactEventHandler<T> | undefined;
1415 onCanPlayCapture?: ReactEventHandler<T> | undefined;
1416 onCanPlayThrough?: ReactEventHandler<T> | undefined;
1417 onCanPlayThroughCapture?: ReactEventHandler<T> | undefined;
1418 onDurationChange?: ReactEventHandler<T> | undefined;
1419 onDurationChangeCapture?: ReactEventHandler<T> | undefined;
1420 onEmptied?: ReactEventHandler<T> | undefined;
1421 onEmptiedCapture?: ReactEventHandler<T> | undefined;
1422 onEncrypted?: ReactEventHandler<T> | undefined;
1423 onEncryptedCapture?: ReactEventHandler<T> | undefined;
1424 onEnded?: ReactEventHandler<T> | undefined;
1425 onEndedCapture?: ReactEventHandler<T> | undefined;
1426 onLoadedData?: ReactEventHandler<T> | undefined;
1427 onLoadedDataCapture?: ReactEventHandler<T> | undefined;
1428 onLoadedMetadata?: ReactEventHandler<T> | undefined;
1429 onLoadedMetadataCapture?: ReactEventHandler<T> | undefined;
1430 onLoadStart?: ReactEventHandler<T> | undefined;
1431 onLoadStartCapture?: ReactEventHandler<T> | undefined;
1432 onPause?: ReactEventHandler<T> | undefined;
1433 onPauseCapture?: ReactEventHandler<T> | undefined;
1434 onPlay?: ReactEventHandler<T> | undefined;
1435 onPlayCapture?: ReactEventHandler<T> | undefined;
1436 onPlaying?: ReactEventHandler<T> | undefined;
1437 onPlayingCapture?: ReactEventHandler<T> | undefined;
1438 onProgress?: ReactEventHandler<T> | undefined;
1439 onProgressCapture?: ReactEventHandler<T> | undefined;
1440 onRateChange?: ReactEventHandler<T> | undefined;
1441 onRateChangeCapture?: ReactEventHandler<T> | undefined;
1442 onSeeked?: ReactEventHandler<T> | undefined;
1443 onSeekedCapture?: ReactEventHandler<T> | undefined;
1444 onSeeking?: ReactEventHandler<T> | undefined;
1445 onSeekingCapture?: ReactEventHandler<T> | undefined;
1446 onStalled?: ReactEventHandler<T> | undefined;
1447 onStalledCapture?: ReactEventHandler<T> | undefined;
1448 onSuspend?: ReactEventHandler<T> | undefined;
1449 onSuspendCapture?: ReactEventHandler<T> | undefined;
1450 onTimeUpdate?: ReactEventHandler<T> | undefined;
1451 onTimeUpdateCapture?: ReactEventHandler<T> | undefined;
1452 onVolumeChange?: ReactEventHandler<T> | undefined;
1453 onVolumeChangeCapture?: ReactEventHandler<T> | undefined;
1454 onWaiting?: ReactEventHandler<T> | undefined;
1455 onWaitingCapture?: ReactEventHandler<T> | undefined;
1456
1457 // MouseEvents
1458 onAuxClick?: MouseEventHandler<T> | undefined;
1459 onAuxClickCapture?: MouseEventHandler<T> | undefined;
1460 onClick?: MouseEventHandler<T> | undefined;
1461 onClickCapture?: MouseEventHandler<T> | undefined;
1462 onContextMenu?: MouseEventHandler<T> | undefined;
1463 onContextMenuCapture?: MouseEventHandler<T> | undefined;
1464 onDoubleClick?: MouseEventHandler<T> | undefined;
1465 onDoubleClickCapture?: MouseEventHandler<T> | undefined;
1466 onDrag?: DragEventHandler<T> | undefined;
1467 onDragCapture?: DragEventHandler<T> | undefined;
1468 onDragEnd?: DragEventHandler<T> | undefined;
1469 onDragEndCapture?: DragEventHandler<T> | undefined;
1470 onDragEnter?: DragEventHandler<T> | undefined;
1471 onDragEnterCapture?: DragEventHandler<T> | undefined;
1472 onDragExit?: DragEventHandler<T> | undefined;
1473 onDragExitCapture?: DragEventHandler<T> | undefined;
1474 onDragLeave?: DragEventHandler<T> | undefined;
1475 onDragLeaveCapture?: DragEventHandler<T> | undefined;
1476 onDragOver?: DragEventHandler<T> | undefined;
1477 onDragOverCapture?: DragEventHandler<T> | undefined;
1478 onDragStart?: DragEventHandler<T> | undefined;
1479 onDragStartCapture?: DragEventHandler<T> | undefined;
1480 onDrop?: DragEventHandler<T> | undefined;
1481 onDropCapture?: DragEventHandler<T> | undefined;
1482 onMouseDown?: MouseEventHandler<T> | undefined;
1483 onMouseDownCapture?: MouseEventHandler<T> | undefined;
1484 onMouseEnter?: MouseEventHandler<T> | undefined;
1485 onMouseLeave?: MouseEventHandler<T> | undefined;
1486 onMouseMove?: MouseEventHandler<T> | undefined;
1487 onMouseMoveCapture?: MouseEventHandler<T> | undefined;
1488 onMouseOut?: MouseEventHandler<T> | undefined;
1489 onMouseOutCapture?: MouseEventHandler<T> | undefined;
1490 onMouseOver?: MouseEventHandler<T> | undefined;
1491 onMouseOverCapture?: MouseEventHandler<T> | undefined;
1492 onMouseUp?: MouseEventHandler<T> | undefined;
1493 onMouseUpCapture?: MouseEventHandler<T> | undefined;
1494
1495 // Selection Events
1496 onSelect?: ReactEventHandler<T> | undefined;
1497 onSelectCapture?: ReactEventHandler<T> | undefined;
1498
1499 // Touch Events
1500 onTouchCancel?: TouchEventHandler<T> | undefined;
1501 onTouchCancelCapture?: TouchEventHandler<T> | undefined;
1502 onTouchEnd?: TouchEventHandler<T> | undefined;
1503 onTouchEndCapture?: TouchEventHandler<T> | undefined;
1504 onTouchMove?: TouchEventHandler<T> | undefined;
1505 onTouchMoveCapture?: TouchEventHandler<T> | undefined;
1506 onTouchStart?: TouchEventHandler<T> | undefined;
1507 onTouchStartCapture?: TouchEventHandler<T> | undefined;
1508
1509 // Pointer Events
1510 onPointerDown?: PointerEventHandler<T> | undefined;
1511 onPointerDownCapture?: PointerEventHandler<T> | undefined;
1512 onPointerMove?: PointerEventHandler<T> | undefined;
1513 onPointerMoveCapture?: PointerEventHandler<T> | undefined;
1514 onPointerUp?: PointerEventHandler<T> | undefined;
1515 onPointerUpCapture?: PointerEventHandler<T> | undefined;
1516 onPointerCancel?: PointerEventHandler<T> | undefined;
1517 onPointerCancelCapture?: PointerEventHandler<T> | undefined;
1518 onPointerEnter?: PointerEventHandler<T> | undefined;
1519 onPointerEnterCapture?: PointerEventHandler<T> | undefined;
1520 onPointerLeave?: PointerEventHandler<T> | undefined;
1521 onPointerLeaveCapture?: PointerEventHandler<T> | undefined;
1522 onPointerOver?: PointerEventHandler<T> | undefined;
1523 onPointerOverCapture?: PointerEventHandler<T> | undefined;
1524 onPointerOut?: PointerEventHandler<T> | undefined;
1525 onPointerOutCapture?: PointerEventHandler<T> | undefined;
1526 onGotPointerCapture?: PointerEventHandler<T> | undefined;
1527 onGotPointerCaptureCapture?: PointerEventHandler<T> | undefined;
1528 onLostPointerCapture?: PointerEventHandler<T> | undefined;
1529 onLostPointerCaptureCapture?: PointerEventHandler<T> | undefined;
1530
1531 // UI Events
1532 onScroll?: UIEventHandler<T> | undefined;
1533 onScrollCapture?: UIEventHandler<T> | undefined;
1534
1535 // Wheel Events
1536 onWheel?: WheelEventHandler<T> | undefined;
1537 onWheelCapture?: WheelEventHandler<T> | undefined;
1538
1539 // Animation Events
1540 onAnimationStart?: AnimationEventHandler<T> | undefined;
1541 onAnimationStartCapture?: AnimationEventHandler<T> | undefined;
1542 onAnimationEnd?: AnimationEventHandler<T> | undefined;
1543 onAnimationEndCapture?: AnimationEventHandler<T> | undefined;
1544 onAnimationIteration?: AnimationEventHandler<T> | undefined;
1545 onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
1546
1547 // Transition Events
1548 onTransitionEnd?: TransitionEventHandler<T> | undefined;
1549 onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
1550 }
1551
1552 export interface CSSProperties extends CSS.Properties<string | number> {
1553 /**
1554 * The index signature was removed to enable closed typing for style
1555 * using CSSType. You're able to use type assertion or module augmentation
1556 * to add properties or an index signature of your own.
1557 *
1558 * For examples and more information, visit:
1559 * https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
1560 */
1561 }
1562
1563 // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
1564 interface AriaAttributes {
1565 /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
1566 'aria-activedescendant'?: string | undefined;
1567 /** 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. */
1568 'aria-atomic'?: Booleanish | undefined;
1569 /**
1570 * 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
1571 * presented if they are made.
1572 */
1573 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both' | undefined;
1574 /** 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. */
1575 'aria-busy'?: Booleanish | undefined;
1576 /**
1577 * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
1578 * @see aria-pressed @see aria-selected.
1579 */
1580 'aria-checked'?: boolean | 'false' | 'mixed' | 'true' | undefined;
1581 /**
1582 * Defines the total number of columns in a table, grid, or treegrid.
1583 * @see aria-colindex.
1584 */
1585 'aria-colcount'?: number | undefined;
1586 /**
1587 * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
1588 * @see aria-colcount @see aria-colspan.
1589 */
1590 'aria-colindex'?: number | undefined;
1591 /**
1592 * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
1593 * @see aria-colindex @see aria-rowspan.
1594 */
1595 'aria-colspan'?: number | undefined;
1596 /**
1597 * Identifies the element (or elements) whose contents or presence are controlled by the current element.
1598 * @see aria-owns.
1599 */
1600 'aria-controls'?: string | undefined;
1601 /** Indicates the element that represents the current item within a container or set of related elements. */
1602 'aria-current'?: boolean | 'false' | 'true' | 'page' | 'step' | 'location' | 'date' | 'time' | undefined;
1603 /**
1604 * Identifies the element (or elements) that describes the object.
1605 * @see aria-labelledby
1606 */
1607 'aria-describedby'?: string | undefined;
1608 /**
1609 * Identifies the element that provides a detailed, extended description for the object.
1610 * @see aria-describedby.
1611 */
1612 'aria-details'?: string | undefined;
1613 /**
1614 * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
1615 * @see aria-hidden @see aria-readonly.
1616 */
1617 'aria-disabled'?: Booleanish | undefined;
1618 /**
1619 * Indicates what functions can be performed when a dragged object is released on the drop target.
1620 * @deprecated in ARIA 1.1
1621 */
1622 'aria-dropeffect'?: 'none' | 'copy' | 'execute' | 'link' | 'move' | 'popup' | undefined;
1623 /**
1624 * Identifies the element that provides an error message for the object.
1625 * @see aria-invalid @see aria-describedby.
1626 */
1627 'aria-errormessage'?: string | undefined;
1628 /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
1629 'aria-expanded'?: Booleanish | undefined;
1630 /**
1631 * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
1632 * allows assistive technology to override the general default of reading in document source order.
1633 */
1634 'aria-flowto'?: string | undefined;
1635 /**
1636 * Indicates an element's "grabbed" state in a drag-and-drop operation.
1637 * @deprecated in ARIA 1.1
1638 */
1639 'aria-grabbed'?: Booleanish | undefined;
1640 /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
1641 'aria-haspopup'?: boolean | 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | undefined;
1642 /**
1643 * Indicates whether the element is exposed to an accessibility API.
1644 * @see aria-disabled.
1645 */
1646 'aria-hidden'?: Booleanish | undefined;
1647 /**
1648 * Indicates the entered value does not conform to the format expected by the application.
1649 * @see aria-errormessage.
1650 */
1651 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling' | undefined;
1652 /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
1653 'aria-keyshortcuts'?: string | undefined;
1654 /**
1655 * Defines a string value that labels the current element.
1656 * @see aria-labelledby.
1657 */
1658 'aria-label'?: string | undefined;
1659 /**
1660 * Identifies the element (or elements) that labels the current element.
1661 * @see aria-describedby.
1662 */
1663 'aria-labelledby'?: string | undefined;
1664 /** Defines the hierarchical level of an element within a structure. */
1665 'aria-level'?: number | undefined;
1666 /** 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. */
1667 'aria-live'?: 'off' | 'assertive' | 'polite' | undefined;
1668 /** Indicates whether an element is modal when displayed. */
1669 'aria-modal'?: Booleanish | undefined;
1670 /** Indicates whether a text box accepts multiple lines of input or only a single line. */
1671 'aria-multiline'?: Booleanish | undefined;
1672 /** Indicates that the user may select more than one item from the current selectable descendants. */
1673 'aria-multiselectable'?: Booleanish | undefined;
1674 /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
1675 'aria-orientation'?: 'horizontal' | 'vertical' | undefined;
1676 /**
1677 * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
1678 * between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
1679 * @see aria-controls.
1680 */
1681 'aria-owns'?: string | undefined;
1682 /**
1683 * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
1684 * A hint could be a sample value or a brief description of the expected format.
1685 */
1686 'aria-placeholder'?: string | undefined;
1687 /**
1688 * 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.
1689 * @see aria-setsize.
1690 */
1691 'aria-posinset'?: number | undefined;
1692 /**
1693 * Indicates the current "pressed" state of toggle buttons.
1694 * @see aria-checked @see aria-selected.
1695 */
1696 'aria-pressed'?: boolean | 'false' | 'mixed' | 'true' | undefined;
1697 /**
1698 * Indicates that the element is not editable, but is otherwise operable.
1699 * @see aria-disabled.
1700 */
1701 'aria-readonly'?: Booleanish | undefined;
1702 /**
1703 * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
1704 * @see aria-atomic.
1705 */
1706 'aria-relevant'?: 'additions' | 'additions removals' | 'additions text' | 'all' | 'removals' | 'removals additions' | 'removals text' | 'text' | 'text additions' | 'text removals' | undefined;
1707 /** Indicates that user input is required on the element before a form may be submitted. */
1708 'aria-required'?: Booleanish | undefined;
1709 /** Defines a human-readable, author-localized description for the role of an element. */
1710 'aria-roledescription'?: string | undefined;
1711 /**
1712 * Defines the total number of rows in a table, grid, or treegrid.
1713 * @see aria-rowindex.
1714 */
1715 'aria-rowcount'?: number | undefined;
1716 /**
1717 * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
1718 * @see aria-rowcount @see aria-rowspan.
1719 */
1720 'aria-rowindex'?: number | undefined;
1721 /**
1722 * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
1723 * @see aria-rowindex @see aria-colspan.
1724 */
1725 'aria-rowspan'?: number | undefined;
1726 /**
1727 * Indicates the current "selected" state of various widgets.
1728 * @see aria-checked @see aria-pressed.
1729 */
1730 'aria-selected'?: Booleanish | undefined;
1731 /**
1732 * 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.
1733 * @see aria-posinset.
1734 */
1735 'aria-setsize'?: number | undefined;
1736 /** Indicates if items in a table or grid are sorted in ascending or descending order. */
1737 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other' | undefined;
1738 /** Defines the maximum allowed value for a range widget. */
1739 'aria-valuemax'?: number | undefined;
1740 /** Defines the minimum allowed value for a range widget. */
1741 'aria-valuemin'?: number | undefined;
1742 /**
1743 * Defines the current value for a range widget.
1744 * @see aria-valuetext.
1745 */
1746 'aria-valuenow'?: number | undefined;
1747 /** Defines the human readable text alternative of aria-valuenow for a range widget. */
1748 'aria-valuetext'?: string | undefined;
1749 }
1750
1751 // All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
1752 type AriaRole =
1753 | 'alert'
1754 | 'alertdialog'
1755 | 'application'
1756 | 'article'
1757 | 'banner'
1758 | 'button'
1759 | 'cell'
1760 | 'checkbox'
1761 | 'columnheader'
1762 | 'combobox'
1763 | 'complementary'
1764 | 'contentinfo'
1765 | 'definition'
1766 | 'dialog'
1767 | 'directory'
1768 | 'document'
1769 | 'feed'
1770 | 'figure'
1771 | 'form'
1772 | 'grid'
1773 | 'gridcell'
1774 | 'group'
1775 | 'heading'
1776 | 'img'
1777 | 'link'
1778 | 'list'
1779 | 'listbox'
1780 | 'listitem'
1781 | 'log'
1782 | 'main'
1783 | 'marquee'
1784 | 'math'
1785 | 'menu'
1786 | 'menubar'
1787 | 'menuitem'
1788 | 'menuitemcheckbox'
1789 | 'menuitemradio'
1790 | 'navigation'
1791 | 'none'
1792 | 'note'
1793 | 'option'
1794 | 'presentation'
1795 | 'progressbar'
1796 | 'radio'
1797 | 'radiogroup'
1798 | 'region'
1799 | 'row'
1800 | 'rowgroup'
1801 | 'rowheader'
1802 | 'scrollbar'
1803 | 'search'
1804 | 'searchbox'
1805 | 'separator'
1806 | 'slider'
1807 | 'spinbutton'
1808 | 'status'
1809 | 'switch'
1810 | 'tab'
1811 | 'table'
1812 | 'tablist'
1813 | 'tabpanel'
1814 | 'term'
1815 | 'textbox'
1816 | 'timer'
1817 | 'toolbar'
1818 | 'tooltip'
1819 | 'tree'
1820 | 'treegrid'
1821 | 'treeitem'
1822 | (string & {});
1823
1824 interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
1825 // React-specific Attributes
1826 defaultChecked?: boolean | undefined;
1827 defaultValue?: string | number | ReadonlyArray<string> | undefined;
1828 suppressContentEditableWarning?: boolean | undefined;
1829 suppressHydrationWarning?: boolean | undefined;
1830
1831 // Standard HTML Attributes
1832 accessKey?: string | undefined;
1833 className?: string | undefined;
1834 contentEditable?: Booleanish | "inherit" | undefined;
1835 contextMenu?: string | undefined;
1836 dir?: string | undefined;
1837 draggable?: Booleanish | undefined;
1838 hidden?: boolean | undefined;
1839 id?: string | undefined;
1840 lang?: string | undefined;
1841 placeholder?: string | undefined;
1842 slot?: string | undefined;
1843 spellCheck?: Booleanish | undefined;
1844 style?: CSSProperties | undefined;
1845 tabIndex?: number | undefined;
1846 title?: string | undefined;
1847 translate?: 'yes' | 'no' | undefined;
1848
1849 // Unknown
1850 radioGroup?: string | undefined; // <command>, <menuitem>
1851
1852 // WAI-ARIA
1853 role?: AriaRole | undefined;
1854
1855 // RDFa Attributes
1856 about?: string | undefined;
1857 datatype?: string | undefined;
1858 inlist?: any;
1859 prefix?: string | undefined;
1860 property?: string | undefined;
1861 resource?: string | undefined;
1862 typeof?: string | undefined;
1863 vocab?: string | undefined;
1864
1865 // Non-standard Attributes
1866 autoCapitalize?: string | undefined;
1867 autoCorrect?: string | undefined;
1868 autoSave?: string | undefined;
1869 color?: string | undefined;
1870 itemProp?: string | undefined;
1871 itemScope?: boolean | undefined;
1872 itemType?: string | undefined;
1873 itemID?: string | undefined;
1874 itemRef?: string | undefined;
1875 results?: number | undefined;
1876 security?: string | undefined;
1877 unselectable?: 'on' | 'off' | undefined;
1878
1879 // Living Standard
1880 /**
1881 * Hints at the type of data that might be entered by the user while editing the element or its contents
1882 * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute
1883 */
1884 inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search' | undefined;
1885 /**
1886 * Specify that a standard HTML element should behave like a defined custom built-in element
1887 * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is
1888 */
1889 is?: string | undefined;
1890 }
1891
1892 interface AllHTMLAttributes<T> extends HTMLAttributes<T> {
1893 // Standard HTML Attributes
1894 accept?: string | undefined;
1895 acceptCharset?: string | undefined;
1896 action?: string | undefined;
1897 allowFullScreen?: boolean | undefined;
1898 allowTransparency?: boolean | undefined;
1899 alt?: string | undefined;
1900 as?: string | undefined;
1901 async?: boolean | undefined;
1902 autoComplete?: string | undefined;
1903 autoFocus?: boolean | undefined;
1904 autoPlay?: boolean | undefined;
1905 capture?: boolean | 'user' | 'environment' | undefined;
1906 cellPadding?: number | string | undefined;
1907 cellSpacing?: number | string | undefined;
1908 charSet?: string | undefined;
1909 challenge?: string | undefined;
1910 checked?: boolean | undefined;
1911 cite?: string | undefined;
1912 classID?: string | undefined;
1913 cols?: number | undefined;
1914 colSpan?: number | undefined;
1915 content?: string | undefined;
1916 controls?: boolean | undefined;
1917 coords?: string | undefined;
1918 crossOrigin?: string | undefined;
1919 data?: string | undefined;
1920 dateTime?: string | undefined;
1921 default?: boolean | undefined;
1922 defer?: boolean | undefined;
1923 disabled?: boolean | undefined;
1924 download?: any;
1925 encType?: string | undefined;
1926 form?: string | undefined;
1927 formAction?: string | undefined;
1928 formEncType?: string | undefined;
1929 formMethod?: string | undefined;
1930 formNoValidate?: boolean | undefined;
1931 formTarget?: string | undefined;
1932 frameBorder?: number | string | undefined;
1933 headers?: string | undefined;
1934 height?: number | string | undefined;
1935 high?: number | undefined;
1936 href?: string | undefined;
1937 hrefLang?: string | undefined;
1938 htmlFor?: string | undefined;
1939 httpEquiv?: string | undefined;
1940 integrity?: string | undefined;
1941 keyParams?: string | undefined;
1942 keyType?: string | undefined;
1943 kind?: string | undefined;
1944 label?: string | undefined;
1945 list?: string | undefined;
1946 loop?: boolean | undefined;
1947 low?: number | undefined;
1948 manifest?: string | undefined;
1949 marginHeight?: number | undefined;
1950 marginWidth?: number | undefined;
1951 max?: number | string | undefined;
1952 maxLength?: number | undefined;
1953 media?: string | undefined;
1954 mediaGroup?: string | undefined;
1955 method?: string | undefined;
1956 min?: number | string | undefined;
1957 minLength?: number | undefined;
1958 multiple?: boolean | undefined;
1959 muted?: boolean | undefined;
1960 name?: string | undefined;
1961 nonce?: string | undefined;
1962 noValidate?: boolean | undefined;
1963 open?: boolean | undefined;
1964 optimum?: number | undefined;
1965 pattern?: string | undefined;
1966 placeholder?: string | undefined;
1967 playsInline?: boolean | undefined;
1968 poster?: string | undefined;
1969 preload?: string | undefined;
1970 readOnly?: boolean | undefined;
1971 rel?: string | undefined;
1972 required?: boolean | undefined;
1973 reversed?: boolean | undefined;
1974 rows?: number | undefined;
1975 rowSpan?: number | undefined;
1976 sandbox?: string | undefined;
1977 scope?: string | undefined;
1978 scoped?: boolean | undefined;
1979 scrolling?: string | undefined;
1980 seamless?: boolean | undefined;
1981 selected?: boolean | undefined;
1982 shape?: string | undefined;
1983 size?: number | undefined;
1984 sizes?: string | undefined;
1985 span?: number | undefined;
1986 src?: string | undefined;
1987 srcDoc?: string | undefined;
1988 srcLang?: string | undefined;
1989 srcSet?: string | undefined;
1990 start?: number | undefined;
1991 step?: number | string | undefined;
1992 summary?: string | undefined;
1993 target?: string | undefined;
1994 type?: string | undefined;
1995 useMap?: string | undefined;
1996 value?: string | ReadonlyArray<string> | number | undefined;
1997 width?: number | string | undefined;
1998 wmode?: string | undefined;
1999 wrap?: string | undefined;
2000 }
2001
2002 type HTMLAttributeReferrerPolicy =
2003 | ''
2004 | 'no-referrer'
2005 | 'no-referrer-when-downgrade'
2006 | 'origin'
2007 | 'origin-when-cross-origin'
2008 | 'same-origin'
2009 | 'strict-origin'
2010 | 'strict-origin-when-cross-origin'
2011 | 'unsafe-url';
2012
2013 type HTMLAttributeAnchorTarget =
2014 | '_self'
2015 | '_blank'
2016 | '_parent'
2017 | '_top'
2018 | (string & {});
2019
2020 interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
2021 download?: any;
2022 href?: string | undefined;
2023 hrefLang?: string | undefined;
2024 media?: string | undefined;
2025 ping?: string | undefined;
2026 rel?: string | undefined;
2027 target?: HTMLAttributeAnchorTarget | undefined;
2028 type?: string | undefined;
2029 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2030 }
2031
2032 interface AudioHTMLAttributes<T> extends MediaHTMLAttributes<T> {}
2033
2034 interface AreaHTMLAttributes<T> extends HTMLAttributes<T> {
2035 alt?: string | undefined;
2036 coords?: string | undefined;
2037 download?: any;
2038 href?: string | undefined;
2039 hrefLang?: string | undefined;
2040 media?: string | undefined;
2041 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2042 rel?: string | undefined;
2043 shape?: string | undefined;
2044 target?: string | undefined;
2045 }
2046
2047 interface BaseHTMLAttributes<T> extends HTMLAttributes<T> {
2048 href?: string | undefined;
2049 target?: string | undefined;
2050 }
2051
2052 interface BlockquoteHTMLAttributes<T> extends HTMLAttributes<T> {
2053 cite?: string | undefined;
2054 }
2055
2056 interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
2057 autoFocus?: boolean | undefined;
2058 disabled?: boolean | undefined;
2059 form?: string | undefined;
2060 formAction?: string | undefined;
2061 formEncType?: string | undefined;
2062 formMethod?: string | undefined;
2063 formNoValidate?: boolean | undefined;
2064 formTarget?: string | undefined;
2065 name?: string | undefined;
2066 type?: 'submit' | 'reset' | 'button' | undefined;
2067 value?: string | ReadonlyArray<string> | number | undefined;
2068 }
2069
2070 interface CanvasHTMLAttributes<T> extends HTMLAttributes<T> {
2071 height?: number | string | undefined;
2072 width?: number | string | undefined;
2073 }
2074
2075 interface ColHTMLAttributes<T> extends HTMLAttributes<T> {
2076 span?: number | undefined;
2077 width?: number | string | undefined;
2078 }
2079
2080 interface ColgroupHTMLAttributes<T> extends HTMLAttributes<T> {
2081 span?: number | undefined;
2082 }
2083
2084 interface DataHTMLAttributes<T> extends HTMLAttributes<T> {
2085 value?: string | ReadonlyArray<string> | number | undefined;
2086 }
2087
2088 interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
2089 open?: boolean | undefined;
2090 onToggle?: ReactEventHandler<T> | undefined;
2091 }
2092
2093 interface DelHTMLAttributes<T> extends HTMLAttributes<T> {
2094 cite?: string | undefined;
2095 dateTime?: string | undefined;
2096 }
2097
2098 interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
2099 open?: boolean | undefined;
2100 }
2101
2102 interface EmbedHTMLAttributes<T> extends HTMLAttributes<T> {
2103 height?: number | string | undefined;
2104 src?: string | undefined;
2105 type?: string | undefined;
2106 width?: number | string | undefined;
2107 }
2108
2109 interface FieldsetHTMLAttributes<T> extends HTMLAttributes<T> {
2110 disabled?: boolean | undefined;
2111 form?: string | undefined;
2112 name?: string | undefined;
2113 }
2114
2115 interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
2116 acceptCharset?: string | undefined;
2117 action?: string | undefined;
2118 autoComplete?: string | undefined;
2119 encType?: string | undefined;
2120 method?: string | undefined;
2121 name?: string | undefined;
2122 noValidate?: boolean | undefined;
2123 target?: string | undefined;
2124 }
2125
2126 interface HtmlHTMLAttributes<T> extends HTMLAttributes<T> {
2127 manifest?: string | undefined;
2128 }
2129
2130 interface IframeHTMLAttributes<T> extends HTMLAttributes<T> {
2131 allow?: string | undefined;
2132 allowFullScreen?: boolean | undefined;
2133 allowTransparency?: boolean | undefined;
2134 /** @deprecated */
2135 frameBorder?: number | string | undefined;
2136 height?: number | string | undefined;
2137 loading?: "eager" | "lazy" | undefined;
2138 /** @deprecated */
2139 marginHeight?: number | undefined;
2140 /** @deprecated */
2141 marginWidth?: number | undefined;
2142 name?: string | undefined;
2143 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2144 sandbox?: string | undefined;
2145 /** @deprecated */
2146 scrolling?: string | undefined;
2147 seamless?: boolean | undefined;
2148 src?: string | undefined;
2149 srcDoc?: string | undefined;
2150 width?: number | string | undefined;
2151 }
2152
2153 interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
2154 alt?: string | undefined;
2155 crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
2156 decoding?: "async" | "auto" | "sync" | undefined;
2157 height?: number | string | undefined;
2158 loading?: "eager" | "lazy" | undefined;
2159 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2160 sizes?: string | undefined;
2161 src?: string | undefined;
2162 srcSet?: string | undefined;
2163 useMap?: string | undefined;
2164 width?: number | string | undefined;
2165 }
2166
2167 interface InsHTMLAttributes<T> extends HTMLAttributes<T> {
2168 cite?: string | undefined;
2169 dateTime?: string | undefined;
2170 }
2171
2172 type HTMLInputTypeAttribute =
2173 | 'button'
2174 | 'checkbox'
2175 | 'color'
2176 | 'date'
2177 | 'datetime-local'
2178 | 'email'
2179 | 'file'
2180 | 'hidden'
2181 | 'image'
2182 | 'month'
2183 | 'number'
2184 | 'password'
2185 | 'radio'
2186 | 'range'
2187 | 'reset'
2188 | 'search'
2189 | 'submit'
2190 | 'tel'
2191 | 'text'
2192 | 'time'
2193 | 'url'
2194 | 'week'
2195 | (string & {});
2196
2197 interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
2198 accept?: string | undefined;
2199 alt?: string | undefined;
2200 autoComplete?: string | undefined;
2201 autoFocus?: boolean | undefined;
2202 capture?: boolean | 'user' | 'environment' | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
2203 checked?: boolean | undefined;
2204 crossOrigin?: string | undefined;
2205 disabled?: boolean | undefined;
2206 enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send' | undefined;
2207 form?: string | undefined;
2208 formAction?: string | undefined;
2209 formEncType?: string | undefined;
2210 formMethod?: string | undefined;
2211 formNoValidate?: boolean | undefined;
2212 formTarget?: string | undefined;
2213 height?: number | string | undefined;
2214 list?: string | undefined;
2215 max?: number | string | undefined;
2216 maxLength?: number | undefined;
2217 min?: number | string | undefined;
2218 minLength?: number | undefined;
2219 multiple?: boolean | undefined;
2220 name?: string | undefined;
2221 pattern?: string | undefined;
2222 placeholder?: string | undefined;
2223 readOnly?: boolean | undefined;
2224 required?: boolean | undefined;
2225 size?: number | undefined;
2226 src?: string | undefined;
2227 step?: number | string | undefined;
2228 type?: HTMLInputTypeAttribute | undefined;
2229 value?: string | ReadonlyArray<string> | number | undefined;
2230 width?: number | string | undefined;
2231
2232 onChange?: ChangeEventHandler<T> | undefined;
2233 }
2234
2235 interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
2236 autoFocus?: boolean | undefined;
2237 challenge?: string | undefined;
2238 disabled?: boolean | undefined;
2239 form?: string | undefined;
2240 keyType?: string | undefined;
2241 keyParams?: string | undefined;
2242 name?: string | undefined;
2243 }
2244
2245 interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
2246 form?: string | undefined;
2247 htmlFor?: string | undefined;
2248 }
2249
2250 interface LiHTMLAttributes<T> extends HTMLAttributes<T> {
2251 value?: string | ReadonlyArray<string> | number | undefined;
2252 }
2253
2254 interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
2255 as?: string | undefined;
2256 crossOrigin?: string | undefined;
2257 href?: string | undefined;
2258 hrefLang?: string | undefined;
2259 integrity?: string | undefined;
2260 media?: string | undefined;
2261 imageSrcSet?: string | undefined;
2262 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2263 rel?: string | undefined;
2264 sizes?: string | undefined;
2265 type?: string | undefined;
2266 charSet?: string | undefined;
2267 }
2268
2269 interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
2270 name?: string | undefined;
2271 }
2272
2273 interface MenuHTMLAttributes<T> extends HTMLAttributes<T> {
2274 type?: string | undefined;
2275 }
2276
2277 interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
2278 autoPlay?: boolean | undefined;
2279 controls?: boolean | undefined;
2280 controlsList?: string | undefined;
2281 crossOrigin?: string | undefined;
2282 loop?: boolean | undefined;
2283 mediaGroup?: string | undefined;
2284 muted?: boolean | undefined;
2285 playsInline?: boolean | undefined;
2286 preload?: string | undefined;
2287 src?: string | undefined;
2288 }
2289
2290 interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
2291 charSet?: string | undefined;
2292 content?: string | undefined;
2293 httpEquiv?: string | undefined;
2294 name?: string | undefined;
2295 media?: string | undefined;
2296 }
2297
2298 interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
2299 form?: string | undefined;
2300 high?: number | undefined;
2301 low?: number | undefined;
2302 max?: number | string | undefined;
2303 min?: number | string | undefined;
2304 optimum?: number | undefined;
2305 value?: string | ReadonlyArray<string> | number | undefined;
2306 }
2307
2308 interface QuoteHTMLAttributes<T> extends HTMLAttributes<T> {
2309 cite?: string | undefined;
2310 }
2311
2312 interface ObjectHTMLAttributes<T> extends HTMLAttributes<T> {
2313 classID?: string | undefined;
2314 data?: string | undefined;
2315 form?: string | undefined;
2316 height?: number | string | undefined;
2317 name?: string | undefined;
2318 type?: string | undefined;
2319 useMap?: string | undefined;
2320 width?: number | string | undefined;
2321 wmode?: string | undefined;
2322 }
2323
2324 interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
2325 reversed?: boolean | undefined;
2326 start?: number | undefined;
2327 type?: '1' | 'a' | 'A' | 'i' | 'I' | undefined;
2328 }
2329
2330 interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
2331 disabled?: boolean | undefined;
2332 label?: string | undefined;
2333 }
2334
2335 interface OptionHTMLAttributes<T> extends HTMLAttributes<T> {
2336 disabled?: boolean | undefined;
2337 label?: string | undefined;
2338 selected?: boolean | undefined;
2339 value?: string | ReadonlyArray<string> | number | undefined;
2340 }
2341
2342 interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
2343 form?: string | undefined;
2344 htmlFor?: string | undefined;
2345 name?: string | undefined;
2346 }
2347
2348 interface ParamHTMLAttributes<T> extends HTMLAttributes<T> {
2349 name?: string | undefined;
2350 value?: string | ReadonlyArray<string> | number | undefined;
2351 }
2352
2353 interface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {
2354 max?: number | string | undefined;
2355 value?: string | ReadonlyArray<string> | number | undefined;
2356 }
2357
2358 interface SlotHTMLAttributes<T> extends HTMLAttributes<T> {
2359 name?: string | undefined;
2360 }
2361
2362 interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
2363 async?: boolean | undefined;
2364 /** @deprecated */
2365 charSet?: string | undefined;
2366 crossOrigin?: string | undefined;
2367 defer?: boolean | undefined;
2368 integrity?: string | undefined;
2369 noModule?: boolean | undefined;
2370 nonce?: string | undefined;
2371 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2372 src?: string | undefined;
2373 type?: string | undefined;
2374 }
2375
2376 interface SelectHTMLAttributes<T> extends HTMLAttributes<T> {
2377 autoComplete?: string | undefined;
2378 autoFocus?: boolean | undefined;
2379 disabled?: boolean | undefined;
2380 form?: string | undefined;
2381 multiple?: boolean | undefined;
2382 name?: string | undefined;
2383 required?: boolean | undefined;
2384 size?: number | undefined;
2385 value?: string | ReadonlyArray<string> | number | undefined;
2386 onChange?: ChangeEventHandler<T> | undefined;
2387 }
2388
2389 interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
2390 height?: number | string | undefined;
2391 media?: string | undefined;
2392 sizes?: string | undefined;
2393 src?: string | undefined;
2394 srcSet?: string | undefined;
2395 type?: string | undefined;
2396 width?: number | string | undefined;
2397 }
2398
2399 interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
2400 media?: string | undefined;
2401 nonce?: string | undefined;
2402 scoped?: boolean | undefined;
2403 type?: string | undefined;
2404 }
2405
2406 interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
2407 cellPadding?: number | string | undefined;
2408 cellSpacing?: number | string | undefined;
2409 summary?: string | undefined;
2410 width?: number | string | undefined;
2411 }
2412
2413 interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
2414 autoComplete?: string | undefined;
2415 autoFocus?: boolean | undefined;
2416 cols?: number | undefined;
2417 dirName?: string | undefined;
2418 disabled?: boolean | undefined;
2419 form?: string | undefined;
2420 maxLength?: number | undefined;
2421 minLength?: number | undefined;
2422 name?: string | undefined;
2423 placeholder?: string | undefined;
2424 readOnly?: boolean | undefined;
2425 required?: boolean | undefined;
2426 rows?: number | undefined;
2427 value?: string | ReadonlyArray<string> | number | undefined;
2428 wrap?: string | undefined;
2429
2430 onChange?: ChangeEventHandler<T> | undefined;
2431 }
2432
2433 interface TdHTMLAttributes<T> extends HTMLAttributes<T> {
2434 align?: "left" | "center" | "right" | "justify" | "char" | undefined;
2435 colSpan?: number | undefined;
2436 headers?: string | undefined;
2437 rowSpan?: number | undefined;
2438 scope?: string | undefined;
2439 abbr?: string | undefined;
2440 height?: number | string | undefined;
2441 width?: number | string | undefined;
2442 valign?: "top" | "middle" | "bottom" | "baseline" | undefined;
2443 }
2444
2445 interface ThHTMLAttributes<T> extends HTMLAttributes<T> {
2446 align?: "left" | "center" | "right" | "justify" | "char" | undefined;
2447 colSpan?: number | undefined;
2448 headers?: string | undefined;
2449 rowSpan?: number | undefined;
2450 scope?: string | undefined;
2451 abbr?: string | undefined;
2452 }
2453
2454 interface TimeHTMLAttributes<T> extends HTMLAttributes<T> {
2455 dateTime?: string | undefined;
2456 }
2457
2458 interface TrackHTMLAttributes<T> extends HTMLAttributes<T> {
2459 default?: boolean | undefined;
2460 kind?: string | undefined;
2461 label?: string | undefined;
2462 src?: string | undefined;
2463 srcLang?: string | undefined;
2464 }
2465
2466 interface VideoHTMLAttributes<T> extends MediaHTMLAttributes<T> {
2467 height?: number | string | undefined;
2468 playsInline?: boolean | undefined;
2469 poster?: string | undefined;
2470 width?: number | string | undefined;
2471 disablePictureInPicture?: boolean | undefined;
2472 disableRemotePlayback?: boolean | undefined;
2473 }
2474
2475 // this list is "complete" in that it contains every SVG attribute
2476 // that React supports, but the types can be improved.
2477 // Full list here: https://facebook.github.io/react/docs/dom-elements.html
2478 //
2479 // The three broad type categories are (in order of restrictiveness):
2480 // - "number | string"
2481 // - "string"
2482 // - union of string literals
2483 interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
2484 // Attributes which also defined in HTMLAttributes
2485 // See comment in SVGDOMPropertyConfig.js
2486 className?: string | undefined;
2487 color?: string | undefined;
2488 height?: number | string | undefined;
2489 id?: string | undefined;
2490 lang?: string | undefined;
2491 max?: number | string | undefined;
2492 media?: string | undefined;
2493 method?: string | undefined;
2494 min?: number | string | undefined;
2495 name?: string | undefined;
2496 style?: CSSProperties | undefined;
2497 target?: string | undefined;
2498 type?: string | undefined;
2499 width?: number | string | undefined;
2500
2501 // Other HTML properties supported by SVG elements in browsers
2502 role?: AriaRole | undefined;
2503 tabIndex?: number | undefined;
2504 crossOrigin?: "anonymous" | "use-credentials" | "" | undefined;
2505
2506 // SVG Specific attributes
2507 accentHeight?: number | string | undefined;
2508 accumulate?: "none" | "sum" | undefined;
2509 additive?: "replace" | "sum" | undefined;
2510 alignmentBaseline?: "auto" | "baseline" | "before-edge" | "text-before-edge" | "middle" | "central" | "after-edge" |
2511 "text-after-edge" | "ideographic" | "alphabetic" | "hanging" | "mathematical" | "inherit" | undefined;
2512 allowReorder?: "no" | "yes" | undefined;
2513 alphabetic?: number | string | undefined;
2514 amplitude?: number | string | undefined;
2515 arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
2516 ascent?: number | string | undefined;
2517 attributeName?: string | undefined;
2518 attributeType?: string | undefined;
2519 autoReverse?: Booleanish | undefined;
2520 azimuth?: number | string | undefined;
2521 baseFrequency?: number | string | undefined;
2522 baselineShift?: number | string | undefined;
2523 baseProfile?: number | string | undefined;
2524 bbox?: number | string | undefined;
2525 begin?: number | string | undefined;
2526 bias?: number | string | undefined;
2527 by?: number | string | undefined;
2528 calcMode?: number | string | undefined;
2529 capHeight?: number | string | undefined;
2530 clip?: number | string | undefined;
2531 clipPath?: string | undefined;
2532 clipPathUnits?: number | string | undefined;
2533 clipRule?: number | string | undefined;
2534 colorInterpolation?: number | string | undefined;
2535 colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
2536 colorProfile?: number | string | undefined;
2537 colorRendering?: number | string | undefined;
2538 contentScriptType?: number | string | undefined;
2539 contentStyleType?: number | string | undefined;
2540 cursor?: number | string | undefined;
2541 cx?: number | string | undefined;
2542 cy?: number | string | undefined;
2543 d?: string | undefined;
2544 decelerate?: number | string | undefined;
2545 descent?: number | string | undefined;
2546 diffuseConstant?: number | string | undefined;
2547 direction?: number | string | undefined;
2548 display?: number | string | undefined;
2549 divisor?: number | string | undefined;
2550 dominantBaseline?: number | string | undefined;
2551 dur?: number | string | undefined;
2552 dx?: number | string | undefined;
2553 dy?: number | string | undefined;
2554 edgeMode?: number | string | undefined;
2555 elevation?: number | string | undefined;
2556 enableBackground?: number | string | undefined;
2557 end?: number | string | undefined;
2558 exponent?: number | string | undefined;
2559 externalResourcesRequired?: Booleanish | undefined;
2560 fill?: string | undefined;
2561 fillOpacity?: number | string | undefined;
2562 fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
2563 filter?: string | undefined;
2564 filterRes?: number | string | undefined;
2565 filterUnits?: number | string | undefined;
2566 floodColor?: number | string | undefined;
2567 floodOpacity?: number | string | undefined;
2568 focusable?: Booleanish | "auto" | undefined;
2569 fontFamily?: string | undefined;
2570 fontSize?: number | string | undefined;
2571 fontSizeAdjust?: number | string | undefined;
2572 fontStretch?: number | string | undefined;
2573 fontStyle?: number | string | undefined;
2574 fontVariant?: number | string | undefined;
2575 fontWeight?: number | string | undefined;
2576 format?: number | string | undefined;
2577 fr?: number | string | undefined;
2578 from?: number | string | undefined;
2579 fx?: number | string | undefined;
2580 fy?: number | string | undefined;
2581 g1?: number | string | undefined;
2582 g2?: number | string | undefined;
2583 glyphName?: number | string | undefined;
2584 glyphOrientationHorizontal?: number | string | undefined;
2585 glyphOrientationVertical?: number | string | undefined;
2586 glyphRef?: number | string | undefined;
2587 gradientTransform?: string | undefined;
2588 gradientUnits?: string | undefined;
2589 hanging?: number | string | undefined;
2590 horizAdvX?: number | string | undefined;
2591 horizOriginX?: number | string | undefined;
2592 href?: string | undefined;
2593 ideographic?: number | string | undefined;
2594 imageRendering?: number | string | undefined;
2595 in2?: number | string | undefined;
2596 in?: string | undefined;
2597 intercept?: number | string | undefined;
2598 k1?: number | string | undefined;
2599 k2?: number | string | undefined;
2600 k3?: number | string | undefined;
2601 k4?: number | string | undefined;
2602 k?: number | string | undefined;
2603 kernelMatrix?: number | string | undefined;
2604 kernelUnitLength?: number | string | undefined;
2605 kerning?: number | string | undefined;
2606 keyPoints?: number | string | undefined;
2607 keySplines?: number | string | undefined;
2608 keyTimes?: number | string | undefined;
2609 lengthAdjust?: number | string | undefined;
2610 letterSpacing?: number | string | undefined;
2611 lightingColor?: number | string | undefined;
2612 limitingConeAngle?: number | string | undefined;
2613 local?: number | string | undefined;
2614 markerEnd?: string | undefined;
2615 markerHeight?: number | string | undefined;
2616 markerMid?: string | undefined;
2617 markerStart?: string | undefined;
2618 markerUnits?: number | string | undefined;
2619 markerWidth?: number | string | undefined;
2620 mask?: string | undefined;
2621 maskContentUnits?: number | string | undefined;
2622 maskUnits?: number | string | undefined;
2623 mathematical?: number | string | undefined;
2624 mode?: number | string | undefined;
2625 numOctaves?: number | string | undefined;
2626 offset?: number | string | undefined;
2627 opacity?: number | string | undefined;
2628 operator?: number | string | undefined;
2629 order?: number | string | undefined;
2630 orient?: number | string | undefined;
2631 orientation?: number | string | undefined;
2632 origin?: number | string | undefined;
2633 overflow?: number | string | undefined;
2634 overlinePosition?: number | string | undefined;
2635 overlineThickness?: number | string | undefined;
2636 paintOrder?: number | string | undefined;
2637 panose1?: number | string | undefined;
2638 path?: string | undefined;
2639 pathLength?: number | string | undefined;
2640 patternContentUnits?: string | undefined;
2641 patternTransform?: number | string | undefined;
2642 patternUnits?: string | undefined;
2643 pointerEvents?: number | string | undefined;
2644 points?: string | undefined;
2645 pointsAtX?: number | string | undefined;
2646 pointsAtY?: number | string | undefined;
2647 pointsAtZ?: number | string | undefined;
2648 preserveAlpha?: Booleanish | undefined;
2649 preserveAspectRatio?: string | undefined;
2650 primitiveUnits?: number | string | undefined;
2651 r?: number | string | undefined;
2652 radius?: number | string | undefined;
2653 refX?: number | string | undefined;
2654 refY?: number | string | undefined;
2655 renderingIntent?: number | string | undefined;
2656 repeatCount?: number | string | undefined;
2657 repeatDur?: number | string | undefined;
2658 requiredExtensions?: number | string | undefined;
2659 requiredFeatures?: number | string | undefined;
2660 restart?: number | string | undefined;
2661 result?: string | undefined;
2662 rotate?: number | string | undefined;
2663 rx?: number | string | undefined;
2664 ry?: number | string | undefined;
2665 scale?: number | string | undefined;
2666 seed?: number | string | undefined;
2667 shapeRendering?: number | string | undefined;
2668 slope?: number | string | undefined;
2669 spacing?: number | string | undefined;
2670 specularConstant?: number | string | undefined;
2671 specularExponent?: number | string | undefined;
2672 speed?: number | string | undefined;
2673 spreadMethod?: string | undefined;
2674 startOffset?: number | string | undefined;
2675 stdDeviation?: number | string | undefined;
2676 stemh?: number | string | undefined;
2677 stemv?: number | string | undefined;
2678 stitchTiles?: number | string | undefined;
2679 stopColor?: string | undefined;
2680 stopOpacity?: number | string | undefined;
2681 strikethroughPosition?: number | string | undefined;
2682 strikethroughThickness?: number | string | undefined;
2683 string?: number | string | undefined;
2684 stroke?: string | undefined;
2685 strokeDasharray?: string | number | undefined;
2686 strokeDashoffset?: string | number | undefined;
2687 strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
2688 strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
2689 strokeMiterlimit?: number | string | undefined;
2690 strokeOpacity?: number | string | undefined;
2691 strokeWidth?: number | string | undefined;
2692 surfaceScale?: number | string | undefined;
2693 systemLanguage?: number | string | undefined;
2694 tableValues?: number | string | undefined;
2695 targetX?: number | string | undefined;
2696 targetY?: number | string | undefined;
2697 textAnchor?: string | undefined;
2698 textDecoration?: number | string | undefined;
2699 textLength?: number | string | undefined;
2700 textRendering?: number | string | undefined;
2701 to?: number | string | undefined;
2702 transform?: string | undefined;
2703 u1?: number | string | undefined;
2704 u2?: number | string | undefined;
2705 underlinePosition?: number | string | undefined;
2706 underlineThickness?: number | string | undefined;
2707 unicode?: number | string | undefined;
2708 unicodeBidi?: number | string | undefined;
2709 unicodeRange?: number | string | undefined;
2710 unitsPerEm?: number | string | undefined;
2711 vAlphabetic?: number | string | undefined;
2712 values?: string | undefined;
2713 vectorEffect?: number | string | undefined;
2714 version?: string | undefined;
2715 vertAdvY?: number | string | undefined;
2716 vertOriginX?: number | string | undefined;
2717 vertOriginY?: number | string | undefined;
2718 vHanging?: number | string | undefined;
2719 vIdeographic?: number | string | undefined;
2720 viewBox?: string | undefined;
2721 viewTarget?: number | string | undefined;
2722 visibility?: number | string | undefined;
2723 vMathematical?: number | string | undefined;
2724 widths?: number | string | undefined;
2725 wordSpacing?: number | string | undefined;
2726 writingMode?: number | string | undefined;
2727 x1?: number | string | undefined;
2728 x2?: number | string | undefined;
2729 x?: number | string | undefined;
2730 xChannelSelector?: string | undefined;
2731 xHeight?: number | string | undefined;
2732 xlinkActuate?: string | undefined;
2733 xlinkArcrole?: string | undefined;
2734 xlinkHref?: string | undefined;
2735 xlinkRole?: string | undefined;
2736 xlinkShow?: string | undefined;
2737 xlinkTitle?: string | undefined;
2738 xlinkType?: string | undefined;
2739 xmlBase?: string | undefined;
2740 xmlLang?: string | undefined;
2741 xmlns?: string | undefined;
2742 xmlnsXlink?: string | undefined;
2743 xmlSpace?: string | undefined;
2744 y1?: number | string | undefined;
2745 y2?: number | string | undefined;
2746 y?: number | string | undefined;
2747 yChannelSelector?: string | undefined;
2748 z?: number | string | undefined;
2749 zoomAndPan?: string | undefined;
2750 }
2751
2752 interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
2753 allowFullScreen?: boolean | undefined;
2754 allowpopups?: boolean | undefined;
2755 autoFocus?: boolean | undefined;
2756 autosize?: boolean | undefined;
2757 blinkfeatures?: string | undefined;
2758 disableblinkfeatures?: string | undefined;
2759 disableguestresize?: boolean | undefined;
2760 disablewebsecurity?: boolean | undefined;
2761 guestinstance?: string | undefined;
2762 httpreferrer?: string | undefined;
2763 nodeintegration?: boolean | undefined;
2764 partition?: string | undefined;
2765 plugins?: boolean | undefined;
2766 preload?: string | undefined;
2767 src?: string | undefined;
2768 useragent?: string | undefined;
2769 webpreferences?: string | undefined;
2770 }
2771
2772 //
2773 // React.DOM
2774 // ----------------------------------------------------------------------
2775
2776 interface ReactHTML {
2777 a: DetailedHTMLFactory<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
2778 abbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2779 address: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2780 area: DetailedHTMLFactory<AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
2781 article: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2782 aside: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2783 audio: DetailedHTMLFactory<AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
2784 b: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2785 base: DetailedHTMLFactory<BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
2786 bdi: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2787 bdo: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2788 big: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2789 blockquote: DetailedHTMLFactory<BlockquoteHTMLAttributes<HTMLElement>, HTMLElement>;
2790 body: DetailedHTMLFactory<HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
2791 br: DetailedHTMLFactory<HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
2792 button: DetailedHTMLFactory<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
2793 canvas: DetailedHTMLFactory<CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
2794 caption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2795 cite: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2796 code: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2797 col: DetailedHTMLFactory<ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
2798 colgroup: DetailedHTMLFactory<ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
2799 data: DetailedHTMLFactory<DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
2800 datalist: DetailedHTMLFactory<HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
2801 dd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2802 del: DetailedHTMLFactory<DelHTMLAttributes<HTMLElement>, HTMLElement>;
2803 details: DetailedHTMLFactory<DetailsHTMLAttributes<HTMLElement>, HTMLElement>;
2804 dfn: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2805 dialog: DetailedHTMLFactory<DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
2806 div: DetailedHTMLFactory<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
2807 dl: DetailedHTMLFactory<HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
2808 dt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2809 em: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2810 embed: DetailedHTMLFactory<EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
2811 fieldset: DetailedHTMLFactory<FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
2812 figcaption: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2813 figure: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2814 footer: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2815 form: DetailedHTMLFactory<FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
2816 h1: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
2817 h2: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
2818 h3: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
2819 h4: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
2820 h5: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
2821 h6: DetailedHTMLFactory<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
2822 head: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLHeadElement>;
2823 header: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2824 hgroup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2825 hr: DetailedHTMLFactory<HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
2826 html: DetailedHTMLFactory<HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
2827 i: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2828 iframe: DetailedHTMLFactory<IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
2829 img: DetailedHTMLFactory<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
2830 input: DetailedHTMLFactory<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
2831 ins: DetailedHTMLFactory<InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
2832 kbd: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2833 keygen: DetailedHTMLFactory<KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
2834 label: DetailedHTMLFactory<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
2835 legend: DetailedHTMLFactory<HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
2836 li: DetailedHTMLFactory<LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
2837 link: DetailedHTMLFactory<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
2838 main: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2839 map: DetailedHTMLFactory<MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
2840 mark: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2841 menu: DetailedHTMLFactory<MenuHTMLAttributes<HTMLElement>, HTMLElement>;
2842 menuitem: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2843 meta: DetailedHTMLFactory<MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
2844 meter: DetailedHTMLFactory<MeterHTMLAttributes<HTMLElement>, HTMLElement>;
2845 nav: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2846 noscript: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2847 object: DetailedHTMLFactory<ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
2848 ol: DetailedHTMLFactory<OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
2849 optgroup: DetailedHTMLFactory<OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
2850 option: DetailedHTMLFactory<OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
2851 output: DetailedHTMLFactory<OutputHTMLAttributes<HTMLElement>, HTMLElement>;
2852 p: DetailedHTMLFactory<HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
2853 param: DetailedHTMLFactory<ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
2854 picture: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2855 pre: DetailedHTMLFactory<HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
2856 progress: DetailedHTMLFactory<ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
2857 q: DetailedHTMLFactory<QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
2858 rp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2859 rt: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2860 ruby: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2861 s: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2862 samp: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2863 slot: DetailedHTMLFactory<SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
2864 script: DetailedHTMLFactory<ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
2865 section: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2866 select: DetailedHTMLFactory<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
2867 small: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2868 source: DetailedHTMLFactory<SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
2869 span: DetailedHTMLFactory<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
2870 strong: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2871 style: DetailedHTMLFactory<StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
2872 sub: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2873 summary: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2874 sup: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2875 table: DetailedHTMLFactory<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
2876 template: DetailedHTMLFactory<HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
2877 tbody: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
2878 td: DetailedHTMLFactory<TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
2879 textarea: DetailedHTMLFactory<TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
2880 tfoot: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
2881 th: DetailedHTMLFactory<ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
2882 thead: DetailedHTMLFactory<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
2883 time: DetailedHTMLFactory<TimeHTMLAttributes<HTMLElement>, HTMLElement>;
2884 title: DetailedHTMLFactory<HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
2885 tr: DetailedHTMLFactory<HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
2886 track: DetailedHTMLFactory<TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
2887 u: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2888 ul: DetailedHTMLFactory<HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
2889 "var": DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2890 video: DetailedHTMLFactory<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
2891 wbr: DetailedHTMLFactory<HTMLAttributes<HTMLElement>, HTMLElement>;
2892 webview: DetailedHTMLFactory<WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
2893 }
2894
2895 interface ReactSVG {
2896 animate: SVGFactory;
2897 circle: SVGFactory;
2898 clipPath: SVGFactory;
2899 defs: SVGFactory;
2900 desc: SVGFactory;
2901 ellipse: SVGFactory;
2902 feBlend: SVGFactory;
2903 feColorMatrix: SVGFactory;
2904 feComponentTransfer: SVGFactory;
2905 feComposite: SVGFactory;
2906 feConvolveMatrix: SVGFactory;
2907 feDiffuseLighting: SVGFactory;
2908 feDisplacementMap: SVGFactory;
2909 feDistantLight: SVGFactory;
2910 feDropShadow: SVGFactory;
2911 feFlood: SVGFactory;
2912 feFuncA: SVGFactory;
2913 feFuncB: SVGFactory;
2914 feFuncG: SVGFactory;
2915 feFuncR: SVGFactory;
2916 feGaussianBlur: SVGFactory;
2917 feImage: SVGFactory;
2918 feMerge: SVGFactory;
2919 feMergeNode: SVGFactory;
2920 feMorphology: SVGFactory;
2921 feOffset: SVGFactory;
2922 fePointLight: SVGFactory;
2923 feSpecularLighting: SVGFactory;
2924 feSpotLight: SVGFactory;
2925 feTile: SVGFactory;
2926 feTurbulence: SVGFactory;
2927 filter: SVGFactory;
2928 foreignObject: SVGFactory;
2929 g: SVGFactory;
2930 image: SVGFactory;
2931 line: SVGFactory;
2932 linearGradient: SVGFactory;
2933 marker: SVGFactory;
2934 mask: SVGFactory;
2935 metadata: SVGFactory;
2936 path: SVGFactory;
2937 pattern: SVGFactory;
2938 polygon: SVGFactory;
2939 polyline: SVGFactory;
2940 radialGradient: SVGFactory;
2941 rect: SVGFactory;
2942 stop: SVGFactory;
2943 svg: SVGFactory;
2944 switch: SVGFactory;
2945 symbol: SVGFactory;
2946 text: SVGFactory;
2947 textPath: SVGFactory;
2948 tspan: SVGFactory;
2949 use: SVGFactory;
2950 view: SVGFactory;
2951 }
2952
2953 interface ReactDOM extends ReactHTML, ReactSVG { }
2954
2955 //
2956 // React.PropTypes
2957 // ----------------------------------------------------------------------
2958
2959 type Validator<T> = PropTypes.Validator<T>;
2960
2961 type Requireable<T> = PropTypes.Requireable<T>;
2962
2963 type ValidationMap<T> = PropTypes.ValidationMap<T>;
2964
2965 type WeakValidationMap<T> = {
2966 [K in keyof T]?: null extends T[K]
2967 ? Validator<T[K] | null | undefined>
2968 : undefined extends T[K]
2969 ? Validator<T[K] | null | undefined>
2970 : Validator<T[K]>
2971 };
2972
2973 interface ReactPropTypes {
2974 any: typeof PropTypes.any;
2975 array: typeof PropTypes.array;
2976 bool: typeof PropTypes.bool;
2977 func: typeof PropTypes.func;
2978 number: typeof PropTypes.number;
2979 object: typeof PropTypes.object;
2980 string: typeof PropTypes.string;
2981 node: typeof PropTypes.node;
2982 element: typeof PropTypes.element;
2983 instanceOf: typeof PropTypes.instanceOf;
2984 oneOf: typeof PropTypes.oneOf;
2985 oneOfType: typeof PropTypes.oneOfType;
2986 arrayOf: typeof PropTypes.arrayOf;
2987 objectOf: typeof PropTypes.objectOf;
2988 shape: typeof PropTypes.shape;
2989 exact: typeof PropTypes.exact;
2990 }
2991
2992 //
2993 // React.Children
2994 // ----------------------------------------------------------------------
2995
2996 interface ReactChildren {
2997 map<T, C>(children: C | ReadonlyArray<C>, fn: (child: C, index: number) => T):
2998 C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
2999 forEach<C>(children: C | ReadonlyArray<C>, fn: (child: C, index: number) => void): void;
3000 count(children: any): number;
3001 only<C>(children: C): C extends any[] ? never : C;
3002 toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
3003 }
3004
3005 //
3006 // Browser Interfaces
3007 // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
3008 // ----------------------------------------------------------------------
3009
3010 interface AbstractView {
3011 styleMedia: StyleMedia;
3012 document: Document;
3013 }
3014
3015 interface Touch {
3016 identifier: number;
3017 target: EventTarget;
3018 screenX: number;
3019 screenY: number;
3020 clientX: number;
3021 clientY: number;
3022 pageX: number;
3023 pageY: number;
3024 }
3025
3026 interface TouchList {
3027 [index: number]: Touch;
3028 length: number;
3029 item(index: number): Touch;
3030 identifiedTouch(identifier: number): Touch;
3031 }
3032
3033 //
3034 // Error Interfaces
3035 // ----------------------------------------------------------------------
3036 interface ErrorInfo {
3037 /**
3038 * Captures which component contained the exception, and its ancestors.
3039 */
3040 componentStack: string;
3041 }
3042}
3043
3044// naked 'any' type in a conditional type will short circuit and union both the then/else branches
3045// so boolean is only resolved for T = any
3046type IsExactlyAny<T> = boolean extends (T extends never ? true : false) ? true : false;
3047
3048type ExactlyAnyPropertyKeys<T> = { [K in keyof T]: IsExactlyAny<T[K]> extends true ? K : never }[keyof T];
3049type NotExactlyAnyPropertyKeys<T> = Exclude<keyof T, ExactlyAnyPropertyKeys<T>>;
3050
3051// Try to resolve ill-defined props like for JS users: props can be any, or sometimes objects with properties of type any
3052type MergePropTypes<P, T> =
3053 // Distribute over P in case it is a union type
3054 P extends any
3055 // If props is type any, use propTypes definitions
3056 ? IsExactlyAny<P> extends true ? T :
3057 // If declared props have indexed properties, ignore inferred props entirely as keyof gets widened
3058 string extends keyof P ? P :
3059 // Prefer declared types which are not exactly any
3060 & Pick<P, NotExactlyAnyPropertyKeys<P>>
3061 // For props which are exactly any, use the type inferred from propTypes if present
3062 & Pick<T, Exclude<keyof T, NotExactlyAnyPropertyKeys<P>>>
3063 // Keep leftover props not specified in propTypes
3064 & Pick<P, Exclude<keyof P, keyof T>>
3065 : never;
3066
3067// Any prop that has a default prop becomes optional, but its type is unchanged
3068// Undeclared default props are augmented into the resulting allowable attributes
3069// If declared props have indexed properties, ignore default props entirely as keyof gets widened
3070// Wrap in an outer-level conditional type to allow distribution over props that are unions
3071type Defaultize<P, D> = P extends any
3072 ? string extends keyof P ? P :
3073 & Pick<P, Exclude<keyof P, keyof D>>
3074 & Partial<Pick<P, Extract<keyof P, keyof D>>>
3075 & Partial<Pick<D, Exclude<keyof D, keyof P>>>
3076 : never;
3077
3078type ReactManagedAttributes<C, P> = C extends { propTypes: infer T; defaultProps: infer D; }
3079 ? Defaultize<MergePropTypes<P, PropTypes.InferProps<T>>, D>
3080 : C extends { propTypes: infer T; }
3081 ? MergePropTypes<P, PropTypes.InferProps<T>>
3082 : C extends { defaultProps: infer D; }
3083 ? Defaultize<P, D>
3084 : P;
3085
3086declare global {
3087 namespace JSX {
3088 interface Element extends React.ReactElement<any, any> { }
3089 interface ElementClass extends React.Component<any> {
3090 render(): React.ReactNode;
3091 }
3092 interface ElementAttributesProperty { props: {}; }
3093 interface ElementChildrenAttribute { children: {}; }
3094
3095 // We can't recurse forever because `type` can't be self-referential;
3096 // let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
3097 type LibraryManagedAttributes<C, P> = C extends React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
3098 ? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
3099 ? ReactManagedAttributes<U, P>
3100 : ReactManagedAttributes<T, P>
3101 : ReactManagedAttributes<C, P>;
3102
3103 interface IntrinsicAttributes extends React.Attributes { }
3104 interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> { }
3105
3106 interface IntrinsicElements {
3107 // HTML
3108 a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
3109 abbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3110 address: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3111 area: React.DetailedHTMLProps<React.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
3112 article: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3113 aside: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3114 audio: React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
3115 b: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3116 base: React.DetailedHTMLProps<React.BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
3117 bdi: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3118 bdo: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3119 big: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3120 blockquote: React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLElement>, HTMLElement>;
3121 body: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
3122 br: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
3123 button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
3124 canvas: React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
3125 caption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3126 cite: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3127 code: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3128 col: React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3129 colgroup: React.DetailedHTMLProps<React.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
3130 data: React.DetailedHTMLProps<React.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
3131 datalist: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
3132 dd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3133 del: React.DetailedHTMLProps<React.DelHTMLAttributes<HTMLElement>, HTMLElement>;
3134 details: React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLElement>, HTMLElement>;
3135 dfn: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3136 dialog: React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
3137 div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
3138 dl: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
3139 dt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3140 em: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3141 embed: React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
3142 fieldset: React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
3143 figcaption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3144 figure: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3145 footer: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3146 form: React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
3147 h1: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3148 h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3149 h3: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3150 h4: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3151 h5: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3152 h6: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
3153 head: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>;
3154 header: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3155 hgroup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3156 hr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
3157 html: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
3158 i: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3159 iframe: React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
3160 img: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
3161 input: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
3162 ins: React.DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
3163 kbd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3164 keygen: React.DetailedHTMLProps<React.KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
3165 label: React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
3166 legend: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
3167 li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
3168 link: React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
3169 main: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3170 map: React.DetailedHTMLProps<React.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
3171 mark: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3172 menu: React.DetailedHTMLProps<React.MenuHTMLAttributes<HTMLElement>, HTMLElement>;
3173 menuitem: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3174 meta: React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
3175 meter: React.DetailedHTMLProps<React.MeterHTMLAttributes<HTMLElement>, HTMLElement>;
3176 nav: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3177 noindex: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3178 noscript: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3179 object: React.DetailedHTMLProps<React.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
3180 ol: React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
3181 optgroup: React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
3182 option: React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
3183 output: React.DetailedHTMLProps<React.OutputHTMLAttributes<HTMLElement>, HTMLElement>;
3184 p: React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
3185 param: React.DetailedHTMLProps<React.ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
3186 picture: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3187 pre: React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
3188 progress: React.DetailedHTMLProps<React.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
3189 q: React.DetailedHTMLProps<React.QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
3190 rp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3191 rt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3192 ruby: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3193 s: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3194 samp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3195 slot: React.DetailedHTMLProps<React.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
3196 script: React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
3197 section: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3198 select: React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
3199 small: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3200 source: React.DetailedHTMLProps<React.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
3201 span: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
3202 strong: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3203 style: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
3204 sub: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3205 summary: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3206 sup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3207 table: React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
3208 template: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
3209 tbody: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
3210 td: React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
3211 textarea: React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
3212 tfoot: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
3213 th: React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
3214 thead: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
3215 time: React.DetailedHTMLProps<React.TimeHTMLAttributes<HTMLElement>, HTMLElement>;
3216 title: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
3217 tr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
3218 track: React.DetailedHTMLProps<React.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
3219 u: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3220 ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
3221 "var": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3222 video: React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
3223 wbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
3224 webview: React.DetailedHTMLProps<React.WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
3225
3226 // SVG
3227 svg: React.SVGProps<SVGSVGElement>;
3228
3229 animate: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now.
3230 animateMotion: React.SVGProps<SVGElement>;
3231 animateTransform: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now.
3232 circle: React.SVGProps<SVGCircleElement>;
3233 clipPath: React.SVGProps<SVGClipPathElement>;
3234 defs: React.SVGProps<SVGDefsElement>;
3235 desc: React.SVGProps<SVGDescElement>;
3236 ellipse: React.SVGProps<SVGEllipseElement>;
3237 feBlend: React.SVGProps<SVGFEBlendElement>;
3238 feColorMatrix: React.SVGProps<SVGFEColorMatrixElement>;
3239 feComponentTransfer: React.SVGProps<SVGFEComponentTransferElement>;
3240 feComposite: React.SVGProps<SVGFECompositeElement>;
3241 feConvolveMatrix: React.SVGProps<SVGFEConvolveMatrixElement>;
3242 feDiffuseLighting: React.SVGProps<SVGFEDiffuseLightingElement>;
3243 feDisplacementMap: React.SVGProps<SVGFEDisplacementMapElement>;
3244 feDistantLight: React.SVGProps<SVGFEDistantLightElement>;
3245 feDropShadow: React.SVGProps<SVGFEDropShadowElement>;
3246 feFlood: React.SVGProps<SVGFEFloodElement>;
3247 feFuncA: React.SVGProps<SVGFEFuncAElement>;
3248 feFuncB: React.SVGProps<SVGFEFuncBElement>;
3249 feFuncG: React.SVGProps<SVGFEFuncGElement>;
3250 feFuncR: React.SVGProps<SVGFEFuncRElement>;
3251 feGaussianBlur: React.SVGProps<SVGFEGaussianBlurElement>;
3252 feImage: React.SVGProps<SVGFEImageElement>;
3253 feMerge: React.SVGProps<SVGFEMergeElement>;
3254 feMergeNode: React.SVGProps<SVGFEMergeNodeElement>;
3255 feMorphology: React.SVGProps<SVGFEMorphologyElement>;
3256 feOffset: React.SVGProps<SVGFEOffsetElement>;
3257 fePointLight: React.SVGProps<SVGFEPointLightElement>;
3258 feSpecularLighting: React.SVGProps<SVGFESpecularLightingElement>;
3259 feSpotLight: React.SVGProps<SVGFESpotLightElement>;
3260 feTile: React.SVGProps<SVGFETileElement>;
3261 feTurbulence: React.SVGProps<SVGFETurbulenceElement>;
3262 filter: React.SVGProps<SVGFilterElement>;
3263 foreignObject: React.SVGProps<SVGForeignObjectElement>;
3264 g: React.SVGProps<SVGGElement>;
3265 image: React.SVGProps<SVGImageElement>;
3266 line: React.SVGProps<SVGLineElement>;
3267 linearGradient: React.SVGProps<SVGLinearGradientElement>;
3268 marker: React.SVGProps<SVGMarkerElement>;
3269 mask: React.SVGProps<SVGMaskElement>;
3270 metadata: React.SVGProps<SVGMetadataElement>;
3271 mpath: React.SVGProps<SVGElement>;
3272 path: React.SVGProps<SVGPathElement>;
3273 pattern: React.SVGProps<SVGPatternElement>;
3274 polygon: React.SVGProps<SVGPolygonElement>;
3275 polyline: React.SVGProps<SVGPolylineElement>;
3276 radialGradient: React.SVGProps<SVGRadialGradientElement>;
3277 rect: React.SVGProps<SVGRectElement>;
3278 stop: React.SVGProps<SVGStopElement>;
3279 switch: React.SVGProps<SVGSwitchElement>;
3280 symbol: React.SVGProps<SVGSymbolElement>;
3281 text: React.SVGProps<SVGTextElement>;
3282 textPath: React.SVGProps<SVGTextPathElement>;
3283 tspan: React.SVGProps<SVGTSpanElement>;
3284 use: React.SVGProps<SVGUseElement>;
3285 view: React.SVGProps<SVGViewElement>;
3286 }
3287 }
3288}
3289
\No newline at end of file