UNPKG

171 kBTypeScriptView Raw
1// NOTE: Users of the `experimental` builds of React should add a reference
2// to 'react/experimental' in their project. See experimental.d.ts's top comment
3// for reference and documentation on how exactly to do it.
4
5/// <reference path="global.d.ts" />
6
7import * as CSS from "csstype";
8
9type NativeAnimationEvent = AnimationEvent;
10type NativeClipboardEvent = ClipboardEvent;
11type NativeCompositionEvent = CompositionEvent;
12type NativeDragEvent = DragEvent;
13type NativeFocusEvent = FocusEvent;
14type NativeKeyboardEvent = KeyboardEvent;
15type NativeMouseEvent = MouseEvent;
16type NativeTouchEvent = TouchEvent;
17type NativePointerEvent = PointerEvent;
18type NativeToggleEvent = ToggleEvent;
19type NativeTransitionEvent = TransitionEvent;
20type NativeUIEvent = UIEvent;
21type NativeWheelEvent = WheelEvent;
22
23/**
24 * Used to represent DOM API's where users can either pass
25 * true or false as a boolean or as its equivalent strings.
26 */
27type Booleanish = boolean | "true" | "false";
28
29/**
30 * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin MDN}
31 */
32type CrossOrigin = "anonymous" | "use-credentials" | "" | undefined;
33
34declare const UNDEFINED_VOID_ONLY: unique symbol;
35
36/**
37 * @internal Use `Awaited<ReactNode>` instead
38 */
39// Helper type to enable `Awaited<ReactNode>`.
40// Must be a copy of the non-thenables of `ReactNode`.
41type AwaitedReactNode =
42 | React.ReactElement
43 | string
44 | number
45 | bigint
46 | Iterable<React.ReactNode>
47 | React.ReactPortal
48 | boolean
49 | null
50 | undefined
51 | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
52 keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
53 ];
54
55/**
56 * The function returned from an effect passed to {@link React.useEffect useEffect},
57 * which can be used to clean up the effect when the component unmounts.
58 *
59 * @see {@link https://react.dev/reference/react/useEffect React Docs}
60 */
61type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };
62type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
63
64// eslint-disable-next-line @definitelytyped/export-just-namespace
65export = React;
66export as namespace React;
67
68declare namespace React {
69 //
70 // React Elements
71 // ----------------------------------------------------------------------
72
73 /**
74 * Used to retrieve the possible components which accept a given set of props.
75 *
76 * Can be passed no type parameters to get a union of all possible components
77 * and tags.
78 *
79 * Is a superset of {@link ComponentType}.
80 *
81 * @template P The props to match against. If not passed, defaults to any.
82 * @template Tag An optional tag to match against. If not passed, attempts to match against all possible tags.
83 *
84 * @example
85 *
86 * ```tsx
87 * // All components and tags (img, embed etc.)
88 * // which accept `src`
89 * type SrcComponents = ElementType<{ src: any }>;
90 * ```
91 *
92 * @example
93 *
94 * ```tsx
95 * // All components
96 * type AllComponents = ElementType;
97 * ```
98 *
99 * @example
100 *
101 * ```tsx
102 * // All custom components which match `src`, and tags which
103 * // match `src`, narrowed down to just `audio` and `embed`
104 * type SrcComponents = ElementType<{ src: any }, 'audio' | 'embed'>;
105 * ```
106 */
107 type ElementType<P = any, Tag extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements> =
108 | { [K in Tag]: P extends JSX.IntrinsicElements[K] ? K : never }[Tag]
109 | ComponentType<P>;
110
111 /**
112 * Represents any user-defined component, either as a function or a class.
113 *
114 * Similar to {@link JSXElementConstructor}, but with extra properties like
115 * {@link FunctionComponent.defaultProps defaultProps }.
116 *
117 * @template P The props the component accepts.
118 *
119 * @see {@link ComponentClass}
120 * @see {@link FunctionComponent}
121 */
122 type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
123
124 /**
125 * Represents any user-defined component, either as a function or a class.
126 *
127 * Similar to {@link ComponentType}, but without extra properties like
128 * {@link FunctionComponent.defaultProps defaultProps }.
129 *
130 * @template P The props the component accepts.
131 */
132 type JSXElementConstructor<P> =
133 | ((
134 props: P,
135 ) => ReactNode | Promise<ReactNode>)
136 // constructor signature must match React.Component
137 | (new(props: P) => Component<any, any>);
138
139 /**
140 * Created by {@link createRef}, or {@link useRef} when passed `null`.
141 *
142 * @template T The type of the ref's value.
143 *
144 * @example
145 *
146 * ```tsx
147 * const ref = createRef<HTMLDivElement>();
148 *
149 * ref.current = document.createElement('div'); // Error
150 * ```
151 */
152 interface RefObject<T> {
153 /**
154 * The current value of the ref.
155 */
156 current: T;
157 }
158
159 interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
160 }
161 /**
162 * A callback fired whenever the ref's value changes.
163 *
164 * @template T The type of the ref's value.
165 *
166 * @see {@link https://react.dev/reference/react-dom/components/common#ref-callback React Docs}
167 *
168 * @example
169 *
170 * ```tsx
171 * <div ref={(node) => console.log(node)} />
172 * ```
173 */
174 type RefCallback<T> = {
175 bivarianceHack(
176 instance: T | null,
177 ):
178 | void
179 | (() => VoidOrUndefinedOnly)
180 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[
181 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES
182 ];
183 }["bivarianceHack"];
184
185 /**
186 * A union type of all possible shapes for React refs.
187 *
188 * @see {@link RefCallback}
189 * @see {@link RefObject}
190 */
191
192 type Ref<T> = RefCallback<T> | RefObject<T | null> | null;
193 /**
194 * @deprecated Use `Ref` instead. String refs are no longer supported.
195 * If you're typing a library with support for React versions with string refs, use `RefAttributes<T>['ref']` instead.
196 */
197 type LegacyRef<T> = Ref<T>;
198 /**
199 * @deprecated Use `ComponentRef<T>` instead
200 *
201 * Retrieves the type of the 'ref' prop for a given component type or tag name.
202 *
203 * @template C The component type.
204 *
205 * @example
206 *
207 * ```tsx
208 * type MyComponentRef = React.ElementRef<typeof MyComponent>;
209 * ```
210 *
211 * @example
212 *
213 * ```tsx
214 * type DivRef = React.ElementRef<'div'>;
215 * ```
216 */
217 type ElementRef<
218 C extends
219 | ForwardRefExoticComponent<any>
220 | { new(props: any): Component<any> }
221 | ((props: any) => ReactNode)
222 | keyof JSX.IntrinsicElements,
223 > = ComponentRef<C>;
224
225 type ComponentState = any;
226
227 /**
228 * A value which uniquely identifies a node among items in an array.
229 *
230 * @see {@link https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key React Docs}
231 */
232 type Key = string | number | bigint;
233
234 /**
235 * @internal The props any component can receive.
236 * You don't have to add this type. All components automatically accept these props.
237 * ```tsx
238 * const Component = () => <div />;
239 * <Component key="one" />
240 * ```
241 *
242 * WARNING: The implementation of a component will never have access to these attributes.
243 * The following example would be incorrect usage because {@link Component} would never have access to `key`:
244 * ```tsx
245 * const Component = (props: React.Attributes) => props.key;
246 * ```
247 */
248 interface Attributes {
249 key?: Key | null | undefined;
250 }
251 /**
252 * The props any component accepting refs can receive.
253 * Class components, built-in browser components (e.g. `div`) and forwardRef components can receive refs and automatically accept these props.
254 * ```tsx
255 * const Component = forwardRef(() => <div />);
256 * <Component ref={(current) => console.log(current)} />
257 * ```
258 *
259 * You only need this type if you manually author the types of props that need to be compatible with legacy refs.
260 * ```tsx
261 * interface Props extends React.RefAttributes<HTMLDivElement> {}
262 * declare const Component: React.FunctionComponent<Props>;
263 * ```
264 *
265 * Otherwise it's simpler to directly use {@link Ref} since you can safely use the
266 * props type to describe to props that a consumer can pass to the component
267 * as well as describing the props the implementation of a component "sees".
268 * {@link RefAttributes} is generally not safe to describe both consumer and seen props.
269 *
270 * ```tsx
271 * interface Props extends {
272 * ref?: React.Ref<HTMLDivElement> | undefined;
273 * }
274 * declare const Component: React.FunctionComponent<Props>;
275 * ```
276 *
277 * WARNING: The implementation of a component will not have access to the same type in versions of React supporting string refs.
278 * The following example would be incorrect usage because {@link Component} would never have access to a `ref` with type `string`
279 * ```tsx
280 * const Component = (props: React.RefAttributes) => props.ref;
281 * ```
282 */
283 interface RefAttributes<T> extends Attributes {
284 /**
285 * Allows getting a ref to the component instance.
286 * Once the component unmounts, React will set `ref.current` to `null`
287 * (or call the ref with `null` if you passed a callback ref).
288 *
289 * @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}
290 */
291 ref?: Ref<T> | undefined;
292 }
293
294 /**
295 * Represents the built-in attributes available to class components.
296 */
297 interface ClassAttributes<T> extends RefAttributes<T> {
298 }
299
300 /**
301 * Represents a JSX element.
302 *
303 * Where {@link ReactNode} represents everything that can be rendered, `ReactElement`
304 * only represents JSX.
305 *
306 * @template P The type of the props object
307 * @template T The type of the component or tag
308 *
309 * @example
310 *
311 * ```tsx
312 * const element: ReactElement = <div />;
313 * ```
314 */
315 interface ReactElement<
316 P = unknown,
317 T extends string | JSXElementConstructor<any> = string | JSXElementConstructor<any>,
318 > {
319 type: T;
320 props: P;
321 key: string | null;
322 }
323
324 /**
325 * @deprecated
326 */
327 interface ReactComponentElement<
328 T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
329 P = Pick<ComponentProps<T>, Exclude<keyof ComponentProps<T>, "key" | "ref">>,
330 > extends ReactElement<P, Exclude<T, number>> {}
331
332 /**
333 * @deprecated Use `ReactElement<P, React.FunctionComponent<P>>`
334 */
335 interface FunctionComponentElement<P> extends ReactElement<P, FunctionComponent<P>> {
336 /**
337 * @deprecated Use `element.props.ref` instead.
338 */
339 ref?: ("ref" extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;
340 }
341
342 /**
343 * @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
344 */
345 type CElement<P, T extends Component<P, ComponentState>> = ComponentElement<P, T>;
346 /**
347 * @deprecated Use `ReactElement<P, React.ComponentClass<P>>`
348 */
349 interface ComponentElement<P, T extends Component<P, ComponentState>> extends ReactElement<P, ComponentClass<P>> {
350 /**
351 * @deprecated Use `element.props.ref` instead.
352 */
353 ref?: Ref<T> | undefined;
354 }
355
356 /**
357 * @deprecated Use {@link ComponentElement} instead.
358 */
359 type ClassicElement<P> = CElement<P, ClassicComponent<P, ComponentState>>;
360
361 // string fallback for custom web-components
362 /**
363 * @deprecated Use `ReactElement<P, string>`
364 */
365 interface DOMElement<P extends HTMLAttributes<T> | SVGAttributes<T>, T extends Element>
366 extends ReactElement<P, string>
367 {
368 /**
369 * @deprecated Use `element.props.ref` instead.
370 */
371 ref: Ref<T>;
372 }
373
374 // ReactHTML for ReactHTMLElement
375 interface ReactHTMLElement<T extends HTMLElement> extends DetailedReactHTMLElement<AllHTMLAttributes<T>, T> {}
376
377 interface DetailedReactHTMLElement<P extends HTMLAttributes<T>, T extends HTMLElement> extends DOMElement<P, T> {
378 type: HTMLElementType;
379 }
380
381 // ReactSVG for ReactSVGElement
382 interface ReactSVGElement extends DOMElement<SVGAttributes<SVGElement>, SVGElement> {
383 type: SVGElementType;
384 }
385
386 interface ReactPortal extends ReactElement {
387 children: ReactNode;
388 }
389
390 /**
391 * Different release channels declare additional types of ReactNode this particular release channel accepts.
392 * App or library types should never augment this interface.
393 */
394 interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {}
395
396 /**
397 * Represents all of the things React can render.
398 *
399 * Where {@link ReactElement} only represents JSX, `ReactNode` represents everything that can be rendered.
400 *
401 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/reactnode/ React TypeScript Cheatsheet}
402 *
403 * @example
404 *
405 * ```tsx
406 * // Typing children
407 * type Props = { children: ReactNode }
408 *
409 * const Component = ({ children }: Props) => <div>{children}</div>
410 *
411 * <Component>hello</Component>
412 * ```
413 *
414 * @example
415 *
416 * ```tsx
417 * // Typing a custom element
418 * type Props = { customElement: ReactNode }
419 *
420 * const Component = ({ customElement }: Props) => <div>{customElement}</div>
421 *
422 * <Component customElement={<div>hello</div>} />
423 * ```
424 */
425 // non-thenables need to be kept in sync with AwaitedReactNode
426 type ReactNode =
427 | ReactElement
428 | string
429 | number
430 | bigint
431 | Iterable<ReactNode>
432 | ReactPortal
433 | boolean
434 | null
435 | undefined
436 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[
437 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES
438 ]
439 | Promise<AwaitedReactNode>;
440
441 //
442 // Top Level API
443 // ----------------------------------------------------------------------
444
445 // DOM Elements
446 // TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
447 function createElement(
448 type: "input",
449 props?: InputHTMLAttributes<HTMLInputElement> & ClassAttributes<HTMLInputElement> | null,
450 ...children: ReactNode[]
451 ): DetailedReactHTMLElement<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
452 function createElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
453 type: HTMLElementType,
454 props?: ClassAttributes<T> & P | null,
455 ...children: ReactNode[]
456 ): DetailedReactHTMLElement<P, T>;
457 function createElement<P extends SVGAttributes<T>, T extends SVGElement>(
458 type: SVGElementType,
459 props?: ClassAttributes<T> & P | null,
460 ...children: ReactNode[]
461 ): ReactSVGElement;
462 function createElement<P extends DOMAttributes<T>, T extends Element>(
463 type: string,
464 props?: ClassAttributes<T> & P | null,
465 ...children: ReactNode[]
466 ): DOMElement<P, T>;
467
468 // Custom components
469
470 function createElement<P extends {}>(
471 type: FunctionComponent<P>,
472 props?: Attributes & P | null,
473 ...children: ReactNode[]
474 ): FunctionComponentElement<P>;
475 function createElement<P extends {}, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
476 type: ClassType<P, T, C>,
477 props?: ClassAttributes<T> & P | null,
478 ...children: ReactNode[]
479 ): CElement<P, T>;
480 function createElement<P extends {}>(
481 type: FunctionComponent<P> | ComponentClass<P> | string,
482 props?: Attributes & P | null,
483 ...children: ReactNode[]
484 ): ReactElement<P>;
485
486 // DOM Elements
487 // ReactHTMLElement
488 function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
489 element: DetailedReactHTMLElement<P, T>,
490 props?: P,
491 ...children: ReactNode[]
492 ): DetailedReactHTMLElement<P, T>;
493 // ReactHTMLElement, less specific
494 function cloneElement<P extends HTMLAttributes<T>, T extends HTMLElement>(
495 element: ReactHTMLElement<T>,
496 props?: P,
497 ...children: ReactNode[]
498 ): ReactHTMLElement<T>;
499 // SVGElement
500 function cloneElement<P extends SVGAttributes<T>, T extends SVGElement>(
501 element: ReactSVGElement,
502 props?: P,
503 ...children: ReactNode[]
504 ): ReactSVGElement;
505 // DOM Element (has to be the last, because type checking stops at first overload that fits)
506 function cloneElement<P extends DOMAttributes<T>, T extends Element>(
507 element: DOMElement<P, T>,
508 props?: DOMAttributes<T> & P,
509 ...children: ReactNode[]
510 ): DOMElement<P, T>;
511
512 // Custom components
513 function cloneElement<P>(
514 element: FunctionComponentElement<P>,
515 props?: Partial<P> & Attributes,
516 ...children: ReactNode[]
517 ): FunctionComponentElement<P>;
518 function cloneElement<P, T extends Component<P, ComponentState>>(
519 element: CElement<P, T>,
520 props?: Partial<P> & ClassAttributes<T>,
521 ...children: ReactNode[]
522 ): CElement<P, T>;
523 function cloneElement<P>(
524 element: ReactElement<P>,
525 props?: Partial<P> & Attributes,
526 ...children: ReactNode[]
527 ): ReactElement<P>;
528
529 /**
530 * Describes the props accepted by a Context {@link Provider}.
531 *
532 * @template T The type of the value the context provides.
533 */
534 interface ProviderProps<T> {
535 value: T;
536 children?: ReactNode | undefined;
537 }
538
539 /**
540 * Describes the props accepted by a Context {@link Consumer}.
541 *
542 * @template T The type of the value the context provides.
543 */
544 interface ConsumerProps<T> {
545 children: (value: T) => ReactNode;
546 }
547
548 /**
549 * An object masquerading as a component. These are created by functions
550 * like {@link forwardRef}, {@link memo}, and {@link createContext}.
551 *
552 * In order to make TypeScript work, we pretend that they are normal
553 * components.
554 *
555 * But they are, in fact, not callable - instead, they are objects which
556 * are treated specially by the renderer.
557 *
558 * @template P The props the component accepts.
559 */
560 interface ExoticComponent<P = {}> {
561 (props: P): ReactNode;
562 readonly $$typeof: symbol;
563 }
564
565 /**
566 * An {@link ExoticComponent} with a `displayName` property applied to it.
567 *
568 * @template P The props the component accepts.
569 */
570 interface NamedExoticComponent<P = {}> extends ExoticComponent<P> {
571 /**
572 * Used in debugging messages. You might want to set it
573 * explicitly if you want to display a different name for
574 * debugging purposes.
575 *
576 * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
577 */
578 displayName?: string | undefined;
579 }
580
581 /**
582 * An {@link ExoticComponent} with a `propTypes` property applied to it.
583 *
584 * @template P The props the component accepts.
585 */
586 interface ProviderExoticComponent<P> extends ExoticComponent<P> {
587 }
588
589 /**
590 * Used to retrieve the type of a context object from a {@link Context}.
591 *
592 * @template C The context object.
593 *
594 * @example
595 *
596 * ```tsx
597 * import { createContext } from 'react';
598 *
599 * const MyContext = createContext({ foo: 'bar' });
600 *
601 * type ContextType = ContextType<typeof MyContext>;
602 * // ContextType = { foo: string }
603 * ```
604 */
605 type ContextType<C extends Context<any>> = C extends Context<infer T> ? T : never;
606
607 /**
608 * Wraps your components to specify the value of this context for all components inside.
609 *
610 * @see {@link https://react.dev/reference/react/createContext#provider React Docs}
611 *
612 * @example
613 *
614 * ```tsx
615 * import { createContext } from 'react';
616 *
617 * const ThemeContext = createContext('light');
618 *
619 * function App() {
620 * return (
621 * <ThemeContext.Provider value="dark">
622 * <Toolbar />
623 * </ThemeContext.Provider>
624 * );
625 * }
626 * ```
627 */
628 type Provider<T> = ProviderExoticComponent<ProviderProps<T>>;
629
630 /**
631 * The old way to read context, before {@link useContext} existed.
632 *
633 * @see {@link https://react.dev/reference/react/createContext#consumer React Docs}
634 *
635 * @example
636 *
637 * ```tsx
638 * import { UserContext } from './user-context';
639 *
640 * function Avatar() {
641 * return (
642 * <UserContext.Consumer>
643 * {user => <img src={user.profileImage} alt={user.name} />}
644 * </UserContext.Consumer>
645 * );
646 * }
647 * ```
648 */
649 type Consumer<T> = ExoticComponent<ConsumerProps<T>>;
650
651 /**
652 * Context lets components pass information deep down without explicitly
653 * passing props.
654 *
655 * Created from {@link createContext}
656 *
657 * @see {@link https://react.dev/learn/passing-data-deeply-with-context React Docs}
658 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
659 *
660 * @example
661 *
662 * ```tsx
663 * import { createContext } from 'react';
664 *
665 * const ThemeContext = createContext('light');
666 * ```
667 */
668 interface Context<T> extends Provider<T> {
669 Provider: Provider<T>;
670 Consumer: Consumer<T>;
671 /**
672 * Used in debugging messages. You might want to set it
673 * explicitly if you want to display a different name for
674 * debugging purposes.
675 *
676 * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
677 */
678 displayName?: string | undefined;
679 }
680
681 /**
682 * Lets you create a {@link Context} that components can provide or read.
683 *
684 * @param defaultValue The value you want the context to have when there is no matching
685 * {@link Provider} in the tree above the component reading the context. This is meant
686 * as a "last resort" fallback.
687 *
688 * @see {@link https://react.dev/reference/react/createContext#reference React Docs}
689 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/context/ React TypeScript Cheatsheet}
690 *
691 * @example
692 *
693 * ```tsx
694 * import { createContext } from 'react';
695 *
696 * const ThemeContext = createContext('light');
697 * function App() {
698 * return (
699 * <ThemeContext value="dark">
700 * <Toolbar />
701 * </ThemeContext>
702 * );
703 * }
704 * ```
705 */
706 function createContext<T>(
707 // If you thought this should be optional, see
708 // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106
709 defaultValue: T,
710 ): Context<T>;
711
712 function isValidElement<P>(object: {} | null | undefined): object is ReactElement<P>;
713
714 const Children: {
715 map<T, C>(
716 children: C | readonly C[],
717 fn: (child: C, index: number) => T,
718 ): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
719 forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
720 count(children: any): number;
721 only<C>(children: C): C extends any[] ? never : C;
722 toArray(children: ReactNode | ReactNode[]): Array<Exclude<ReactNode, boolean | null | undefined>>;
723 };
724 /**
725 * Lets you group elements without a wrapper node.
726 *
727 * @see {@link https://react.dev/reference/react/Fragment React Docs}
728 *
729 * @example
730 *
731 * ```tsx
732 * import { Fragment } from 'react';
733 *
734 * <Fragment>
735 * <td>Hello</td>
736 * <td>World</td>
737 * </Fragment>
738 * ```
739 *
740 * @example
741 *
742 * ```tsx
743 * // Using the <></> shorthand syntax:
744 *
745 * <>
746 * <td>Hello</td>
747 * <td>World</td>
748 * </>
749 * ```
750 */
751 const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;
752
753 /**
754 * Lets you find common bugs in your components early during development.
755 *
756 * @see {@link https://react.dev/reference/react/StrictMode React Docs}
757 *
758 * @example
759 *
760 * ```tsx
761 * import { StrictMode } from 'react';
762 *
763 * <StrictMode>
764 * <App />
765 * </StrictMode>
766 * ```
767 */
768 const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;
769
770 /**
771 * The props accepted by {@link Suspense}.
772 *
773 * @see {@link https://react.dev/reference/react/Suspense React Docs}
774 */
775 interface SuspenseProps {
776 children?: ReactNode | undefined;
777
778 /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
779 fallback?: ReactNode;
780
781 /**
782 * A name for this Suspense boundary for instrumentation purposes.
783 * The name will help identify this boundary in React DevTools.
784 */
785 name?: string | undefined;
786 }
787
788 /**
789 * Lets you display a fallback until its children have finished loading.
790 *
791 * @see {@link https://react.dev/reference/react/Suspense React Docs}
792 *
793 * @example
794 *
795 * ```tsx
796 * import { Suspense } from 'react';
797 *
798 * <Suspense fallback={<Loading />}>
799 * <ProfileDetails />
800 * </Suspense>
801 * ```
802 */
803 const Suspense: ExoticComponent<SuspenseProps>;
804 const version: string;
805
806 /**
807 * The callback passed to {@link ProfilerProps.onRender}.
808 *
809 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
810 */
811 type ProfilerOnRenderCallback = (
812 /**
813 * The string id prop of the {@link Profiler} tree that has just committed. This lets
814 * you identify which part of the tree was committed if you are using multiple
815 * profilers.
816 *
817 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
818 */
819 id: string,
820 /**
821 * This lets you know whether the tree has just been mounted for the first time
822 * or re-rendered due to a change in props, state, or hooks.
823 *
824 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
825 */
826 phase: "mount" | "update" | "nested-update",
827 /**
828 * The number of milliseconds spent rendering the {@link Profiler} and its descendants
829 * for the current update. This indicates how well the subtree makes use of
830 * memoization (e.g. {@link memo} and {@link useMemo}). Ideally this value should decrease
831 * significantly after the initial mount as many of the descendants will only need to
832 * re-render if their specific props change.
833 *
834 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
835 */
836 actualDuration: number,
837 /**
838 * The number of milliseconds estimating how much time it would take to re-render the entire
839 * {@link Profiler} subtree without any optimizations. It is calculated by summing up the most
840 * recent render durations of each component in the tree. This value estimates a worst-case
841 * cost of rendering (e.g. the initial mount or a tree with no memoization). Compare
842 * {@link actualDuration} against it to see if memoization is working.
843 *
844 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
845 */
846 baseDuration: number,
847 /**
848 * A numeric timestamp for when React began rendering the current update.
849 *
850 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
851 */
852 startTime: number,
853 /**
854 * A numeric timestamp for when React committed the current update. This value is shared
855 * between all profilers in a commit, enabling them to be grouped if desirable.
856 *
857 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
858 */
859 commitTime: number,
860 ) => void;
861
862 /**
863 * The props accepted by {@link Profiler}.
864 *
865 * @see {@link https://react.dev/reference/react/Profiler React Docs}
866 */
867 interface ProfilerProps {
868 children?: ReactNode | undefined;
869 id: string;
870 onRender: ProfilerOnRenderCallback;
871 }
872
873 /**
874 * Lets you measure rendering performance of a React tree programmatically.
875 *
876 * @see {@link https://react.dev/reference/react/Profiler#onrender-callback React Docs}
877 *
878 * @example
879 *
880 * ```tsx
881 * <Profiler id="App" onRender={onRender}>
882 * <App />
883 * </Profiler>
884 * ```
885 */
886 const Profiler: ExoticComponent<ProfilerProps>;
887
888 //
889 // Component API
890 // ----------------------------------------------------------------------
891
892 type ReactInstance = Component<any> | Element;
893
894 // Base component for plain JS classes
895 interface Component<P = {}, S = {}, SS = any> extends ComponentLifecycle<P, S, SS> {}
896 class Component<P, S> {
897 /**
898 * If set, `this.context` will be set at runtime to the current value of the given Context.
899 *
900 * @example
901 *
902 * ```ts
903 * type MyContext = number
904 * const Ctx = React.createContext<MyContext>(0)
905 *
906 * class Foo extends React.Component {
907 * static contextType = Ctx
908 * context!: React.ContextType<typeof Ctx>
909 * render () {
910 * return <>My context's value: {this.context}</>;
911 * }
912 * }
913 * ```
914 *
915 * @see {@link https://react.dev/reference/react/Component#static-contexttype}
916 */
917 static contextType?: Context<any> | undefined;
918
919 /**
920 * Ignored by React.
921 * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
922 */
923 static propTypes?: any;
924
925 /**
926 * If using the new style context, re-declare this in your class to be the
927 * `React.ContextType` of your `static contextType`.
928 * Should be used with type annotation or static contextType.
929 *
930 * @example
931 * ```ts
932 * static contextType = MyContext
933 * // For TS pre-3.7:
934 * context!: React.ContextType<typeof MyContext>
935 * // For TS 3.7 and above:
936 * declare context: React.ContextType<typeof MyContext>
937 * ```
938 *
939 * @see {@link https://react.dev/reference/react/Component#context React Docs}
940 */
941 context: unknown;
942
943 // Keep in sync with constructor signature of JSXElementConstructor and ComponentClass.
944 constructor(props: P);
945
946 // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.
947 // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257
948 // Also, the ` | S` allows intellisense to not be dumbisense
949 setState<K extends keyof S>(
950 state: ((prevState: Readonly<S>, props: Readonly<P>) => Pick<S, K> | S | null) | (Pick<S, K> | S | null),
951 callback?: () => void,
952 ): void;
953
954 forceUpdate(callback?: () => void): void;
955 render(): ReactNode;
956
957 readonly props: Readonly<P>;
958 state: Readonly<S>;
959 }
960
961 class PureComponent<P = {}, S = {}, SS = any> extends Component<P, S, SS> {}
962
963 /**
964 * @deprecated Use `ClassicComponent` from `create-react-class`
965 *
966 * @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
967 * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
968 */
969 interface ClassicComponent<P = {}, S = {}> extends Component<P, S> {
970 replaceState(nextState: S, callback?: () => void): void;
971 isMounted(): boolean;
972 getInitialState?(): S;
973 }
974
975 //
976 // Class Interfaces
977 // ----------------------------------------------------------------------
978
979 /**
980 * Represents the type of a function component. Can optionally
981 * receive a type argument that represents the props the component
982 * receives.
983 *
984 * @template P The props the component accepts.
985 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}
986 * @alias for {@link FunctionComponent}
987 *
988 * @example
989 *
990 * ```tsx
991 * // With props:
992 * type Props = { name: string }
993 *
994 * const MyComponent: FC<Props> = (props) => {
995 * return <div>{props.name}</div>
996 * }
997 * ```
998 *
999 * @example
1000 *
1001 * ```tsx
1002 * // Without props:
1003 * const MyComponentWithoutProps: FC = () => {
1004 * return <div>MyComponentWithoutProps</div>
1005 * }
1006 * ```
1007 */
1008 type FC<P = {}> = FunctionComponent<P>;
1009
1010 /**
1011 * Represents the type of a function component. Can optionally
1012 * receive a type argument that represents the props the component
1013 * accepts.
1014 *
1015 * @template P The props the component accepts.
1016 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components React TypeScript Cheatsheet}
1017 *
1018 * @example
1019 *
1020 * ```tsx
1021 * // With props:
1022 * type Props = { name: string }
1023 *
1024 * const MyComponent: FunctionComponent<Props> = (props) => {
1025 * return <div>{props.name}</div>
1026 * }
1027 * ```
1028 *
1029 * @example
1030 *
1031 * ```tsx
1032 * // Without props:
1033 * const MyComponentWithoutProps: FunctionComponent = () => {
1034 * return <div>MyComponentWithoutProps</div>
1035 * }
1036 * ```
1037 */
1038 interface FunctionComponent<P = {}> {
1039 (props: P): ReactNode | Promise<ReactNode>;
1040 /**
1041 * Ignored by React.
1042 * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1043 */
1044 propTypes?: any;
1045 /**
1046 * Used in debugging messages. You might want to set it
1047 * explicitly if you want to display a different name for
1048 * debugging purposes.
1049 *
1050 * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
1051 *
1052 * @example
1053 *
1054 * ```tsx
1055 *
1056 * const MyComponent: FC = () => {
1057 * return <div>Hello!</div>
1058 * }
1059 *
1060 * MyComponent.displayName = 'MyAwesomeComponent'
1061 * ```
1062 */
1063 displayName?: string | undefined;
1064 }
1065
1066 /**
1067 * The type of the ref received by a {@link ForwardRefRenderFunction}.
1068 *
1069 * @see {@link ForwardRefRenderFunction}
1070 */
1071 // Making T nullable is assuming the refs will be managed by React or the component impl will write it somewhere else.
1072 // But this isn't necessarily true. We haven't heard complains about it yet and hopefully `forwardRef` is removed from React before we do.
1073 type ForwardedRef<T> = ((instance: T | null) => void) | RefObject<T | null> | null;
1074
1075 /**
1076 * The type of the function passed to {@link forwardRef}. This is considered different
1077 * to a normal {@link FunctionComponent} because it receives an additional argument,
1078 *
1079 * @param props Props passed to the component, if any.
1080 * @param ref A ref forwarded to the component of type {@link ForwardedRef}.
1081 *
1082 * @template T The type of the forwarded ref.
1083 * @template P The type of the props the component accepts.
1084 *
1085 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}
1086 * @see {@link forwardRef}
1087 */
1088 interface ForwardRefRenderFunction<T, P = {}> {
1089 (props: P, ref: ForwardedRef<T>): ReactNode;
1090 /**
1091 * Used in debugging messages. You might want to set it
1092 * explicitly if you want to display a different name for
1093 * debugging purposes.
1094 *
1095 * Will show `ForwardRef(${Component.displayName || Component.name})`
1096 * in devtools by default, but can be given its own specific name.
1097 *
1098 * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
1099 */
1100 displayName?: string | undefined;
1101 /**
1102 * Ignored by React.
1103 * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1104 */
1105 propTypes?: any;
1106 }
1107
1108 /**
1109 * Represents a component class in React.
1110 *
1111 * @template P The props the component accepts.
1112 * @template S The internal state of the component.
1113 */
1114 interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
1115 // constructor signature must match React.Component
1116 new(props: P): Component<P, S>;
1117 /**
1118 * Ignored by React.
1119 * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1120 */
1121 propTypes?: any;
1122 contextType?: Context<any> | undefined;
1123 defaultProps?: Partial<P> | undefined;
1124 /**
1125 * Used in debugging messages. You might want to set it
1126 * explicitly if you want to display a different name for
1127 * debugging purposes.
1128 *
1129 * @see {@link https://legacy.reactjs.org/docs/react-component.html#displayname Legacy React Docs}
1130 */
1131 displayName?: string | undefined;
1132 }
1133
1134 /**
1135 * @deprecated Use `ClassicComponentClass` from `create-react-class`
1136 *
1137 * @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
1138 * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
1139 */
1140 interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
1141 new(props: P): ClassicComponent<P, ComponentState>;
1142 getDefaultProps?(): P;
1143 }
1144
1145 /**
1146 * Used in {@link createElement} and {@link createFactory} to represent
1147 * a class.
1148 *
1149 * An intersection type is used to infer multiple type parameters from
1150 * a single argument, which is useful for many top-level API defs.
1151 * See {@link https://github.com/Microsoft/TypeScript/issues/7234 this GitHub issue}
1152 * for more info.
1153 */
1154 type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
1155 & C
1156 & (new(props: P) => T);
1157
1158 //
1159 // Component Specs and Lifecycle
1160 // ----------------------------------------------------------------------
1161
1162 // This should actually be something like `Lifecycle<P, S> | DeprecatedLifecycle<P, S>`,
1163 // as React will _not_ call the deprecated lifecycle methods if any of the new lifecycle
1164 // methods are present.
1165 interface ComponentLifecycle<P, S, SS = any> extends NewLifecycle<P, S, SS>, DeprecatedLifecycle<P, S> {
1166 /**
1167 * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
1168 */
1169 componentDidMount?(): void;
1170 /**
1171 * Called to determine whether the change in props and state should trigger a re-render.
1172 *
1173 * `Component` always returns true.
1174 * `PureComponent` implements a shallow comparison on props and state and returns true if any
1175 * props or states have changed.
1176 *
1177 * If false is returned, {@link Component.render}, `componentWillUpdate`
1178 * and `componentDidUpdate` will not be called.
1179 */
1180 shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): boolean;
1181 /**
1182 * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as
1183 * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.
1184 */
1185 componentWillUnmount?(): void;
1186 /**
1187 * Catches exceptions generated in descendant components. Unhandled exceptions will cause
1188 * the entire component tree to unmount.
1189 */
1190 componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;
1191 }
1192
1193 // Unfortunately, we have no way of declaring that the component constructor must implement this
1194 interface StaticLifecycle<P, S> {
1195 getDerivedStateFromProps?: GetDerivedStateFromProps<P, S> | undefined;
1196 getDerivedStateFromError?: GetDerivedStateFromError<P, S> | undefined;
1197 }
1198
1199 type GetDerivedStateFromProps<P, S> =
1200 /**
1201 * Returns an update to a component's state based on its new props and old state.
1202 *
1203 * Note: its presence prevents any of the deprecated lifecycle methods from being invoked
1204 */
1205 (nextProps: Readonly<P>, prevState: S) => Partial<S> | null;
1206
1207 type GetDerivedStateFromError<P, S> =
1208 /**
1209 * This lifecycle is invoked after an error has been thrown by a descendant component.
1210 * It receives the error that was thrown as a parameter and should return a value to update state.
1211 *
1212 * Note: its presence prevents any of the deprecated lifecycle methods from being invoked
1213 */
1214 (error: any) => Partial<S> | null;
1215
1216 // This should be "infer SS" but can't use it yet
1217 interface NewLifecycle<P, S, SS> {
1218 /**
1219 * Runs before React applies the result of {@link Component.render render} to the document, and
1220 * returns an object to be given to {@link componentDidUpdate}. Useful for saving
1221 * things such as scroll position before {@link Component.render render} causes changes to it.
1222 *
1223 * Note: the presence of this method prevents any of the deprecated
1224 * lifecycle events from running.
1225 */
1226 getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>): SS | null;
1227 /**
1228 * Called immediately after updating occurs. Not called for the initial render.
1229 *
1230 * The snapshot is only present if {@link getSnapshotBeforeUpdate} is present and returns non-null.
1231 */
1232 componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<S>, snapshot?: SS): void;
1233 }
1234
1235 interface DeprecatedLifecycle<P, S> {
1236 /**
1237 * Called immediately before mounting occurs, and before {@link Component.render}.
1238 * Avoid introducing any side-effects or subscriptions in this method.
1239 *
1240 * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
1241 * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1242 * this from being invoked.
1243 *
1244 * @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead; will stop working in React 17
1245 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
1246 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1247 */
1248 componentWillMount?(): void;
1249 /**
1250 * Called immediately before mounting occurs, and before {@link Component.render}.
1251 * Avoid introducing any side-effects or subscriptions in this method.
1252 *
1253 * This method will not stop working in React 17.
1254 *
1255 * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
1256 * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1257 * this from being invoked.
1258 *
1259 * @deprecated 16.3, use {@link ComponentLifecycle.componentDidMount componentDidMount} or the constructor instead
1260 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state}
1261 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1262 */
1263 UNSAFE_componentWillMount?(): void;
1264 /**
1265 * Called when the component may be receiving new props.
1266 * React may call this even if props have not changed, so be sure to compare new and existing
1267 * props if you only want to handle changes.
1268 *
1269 * Calling {@link Component.setState} generally does not trigger this method.
1270 *
1271 * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
1272 * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1273 * this from being invoked.
1274 *
1275 * @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead; will stop working in React 17
1276 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1277 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1278 */
1279 componentWillReceiveProps?(nextProps: Readonly<P>): void;
1280 /**
1281 * Called when the component may be receiving new props.
1282 * React may call this even if props have not changed, so be sure to compare new and existing
1283 * props if you only want to handle changes.
1284 *
1285 * Calling {@link Component.setState} generally does not trigger this method.
1286 *
1287 * This method will not stop working in React 17.
1288 *
1289 * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
1290 * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1291 * this from being invoked.
1292 *
1293 * @deprecated 16.3, use static {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} instead
1294 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props}
1295 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1296 */
1297 UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>): void;
1298 /**
1299 * Called immediately before rendering when new props or state is received. Not called for the initial render.
1300 *
1301 * Note: You cannot call {@link Component.setState} here.
1302 *
1303 * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
1304 * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1305 * this from being invoked.
1306 *
1307 * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17
1308 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
1309 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1310 */
1311 componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
1312 /**
1313 * Called immediately before rendering when new props or state is received. Not called for the initial render.
1314 *
1315 * Note: You cannot call {@link Component.setState} here.
1316 *
1317 * This method will not stop working in React 17.
1318 *
1319 * Note: the presence of {@link NewLifecycle.getSnapshotBeforeUpdate getSnapshotBeforeUpdate}
1320 * or {@link StaticLifecycle.getDerivedStateFromProps getDerivedStateFromProps} prevents
1321 * this from being invoked.
1322 *
1323 * @deprecated 16.3, use getSnapshotBeforeUpdate instead
1324 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update}
1325 * @see {@link https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path}
1326 */
1327 UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>): void;
1328 }
1329
1330 function createRef<T>(): RefObject<T | null>;
1331
1332 /**
1333 * The type of the component returned from {@link forwardRef}.
1334 *
1335 * @template P The props the component accepts, if any.
1336 *
1337 * @see {@link ExoticComponent}
1338 */
1339 interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
1340 /**
1341 * Ignored by React.
1342 * @deprecated Only kept in types for backwards compatibility. Will be removed in a future major release.
1343 */
1344 propTypes?: any;
1345 }
1346
1347 /**
1348 * Lets your component expose a DOM node to a parent component
1349 * using a ref.
1350 *
1351 * @see {@link https://react.dev/reference/react/forwardRef React Docs}
1352 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/forward_and_create_ref/ React TypeScript Cheatsheet}
1353 *
1354 * @param render See the {@link ForwardRefRenderFunction}.
1355 *
1356 * @template T The type of the DOM node.
1357 * @template P The props the component accepts, if any.
1358 *
1359 * @example
1360 *
1361 * ```tsx
1362 * interface Props {
1363 * children?: ReactNode;
1364 * type: "submit" | "button";
1365 * }
1366 *
1367 * export const FancyButton = forwardRef<HTMLButtonElement, Props>((props, ref) => (
1368 * <button ref={ref} className="MyClassName" type={props.type}>
1369 * {props.children}
1370 * </button>
1371 * ));
1372 * ```
1373 */
1374 function forwardRef<T, P = {}>(
1375 render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
1376 ): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
1377
1378 /**
1379 * Omits the 'ref' attribute from the given props object.
1380 *
1381 * @template Props The props object type.
1382 */
1383 type PropsWithoutRef<Props> =
1384 // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.
1385 // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
1386 // https://github.com/Microsoft/TypeScript/issues/28339
1387 Props extends any ? ("ref" extends keyof Props ? Omit<Props, "ref"> : Props) : Props;
1388 /**
1389 * Ensures that the props do not include string ref, which cannot be forwarded
1390 * @deprecated Use `Props` directly. `PropsWithRef<Props>` is just an alias for `Props`
1391 */
1392 type PropsWithRef<Props> = Props;
1393
1394 type PropsWithChildren<P = unknown> = P & { children?: ReactNode | undefined };
1395
1396 /**
1397 * Used to retrieve the props a component accepts. Can either be passed a string,
1398 * indicating a DOM element (e.g. 'div', 'span', etc.) or the type of a React
1399 * component.
1400 *
1401 * It's usually better to use {@link ComponentPropsWithRef} or {@link ComponentPropsWithoutRef}
1402 * instead of this type, as they let you be explicit about whether or not to include
1403 * the `ref` prop.
1404 *
1405 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}
1406 *
1407 * @example
1408 *
1409 * ```tsx
1410 * // Retrieves the props an 'input' element accepts
1411 * type InputProps = React.ComponentProps<'input'>;
1412 * ```
1413 *
1414 * @example
1415 *
1416 * ```tsx
1417 * const MyComponent = (props: { foo: number, bar: string }) => <div />;
1418 *
1419 * // Retrieves the props 'MyComponent' accepts
1420 * type MyComponentProps = React.ComponentProps<typeof MyComponent>;
1421 * ```
1422 */
1423 type ComponentProps<T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>> = T extends
1424 JSXElementConstructor<infer Props> ? Props
1425 : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
1426 : {};
1427
1428 /**
1429 * Used to retrieve the props a component accepts with its ref. Can either be
1430 * passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the
1431 * type of a React component.
1432 *
1433 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}
1434 *
1435 * @example
1436 *
1437 * ```tsx
1438 * // Retrieves the props an 'input' element accepts
1439 * type InputProps = React.ComponentPropsWithRef<'input'>;
1440 * ```
1441 *
1442 * @example
1443 *
1444 * ```tsx
1445 * const MyComponent = (props: { foo: number, bar: string }) => <div />;
1446 *
1447 * // Retrieves the props 'MyComponent' accepts
1448 * type MyComponentPropsWithRef = React.ComponentPropsWithRef<typeof MyComponent>;
1449 * ```
1450 */
1451 type ComponentPropsWithRef<T extends ElementType> = T extends JSXElementConstructor<infer Props>
1452 // If it's a class i.e. newable we're dealing with a class component
1453 ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1454 : Props
1455 : ComponentProps<T>;
1456 /**
1457 * Used to retrieve the props a custom component accepts with its ref.
1458 *
1459 * Unlike {@link ComponentPropsWithRef}, this only works with custom
1460 * components, i.e. components you define yourself. This is to improve
1461 * type-checking performance.
1462 *
1463 * @example
1464 *
1465 * ```tsx
1466 * const MyComponent = (props: { foo: number, bar: string }) => <div />;
1467 *
1468 * // Retrieves the props 'MyComponent' accepts
1469 * type MyComponentPropsWithRef = React.CustomComponentPropsWithRef<typeof MyComponent>;
1470 * ```
1471 */
1472 type CustomComponentPropsWithRef<T extends ComponentType> = T extends JSXElementConstructor<infer Props>
1473 // If it's a class i.e. newable we're dealing with a class component
1474 ? T extends abstract new(args: any) => any ? PropsWithoutRef<Props> & RefAttributes<InstanceType<T>>
1475 : Props
1476 : never;
1477
1478 /**
1479 * Used to retrieve the props a component accepts without its ref. Can either be
1480 * passed a string, indicating a DOM element (e.g. 'div', 'span', etc.) or the
1481 * type of a React component.
1482 *
1483 * @see {@link https://react-typescript-cheatsheet.netlify.app/docs/react-types/componentprops/ React TypeScript Cheatsheet}
1484 *
1485 * @example
1486 *
1487 * ```tsx
1488 * // Retrieves the props an 'input' element accepts
1489 * type InputProps = React.ComponentPropsWithoutRef<'input'>;
1490 * ```
1491 *
1492 * @example
1493 *
1494 * ```tsx
1495 * const MyComponent = (props: { foo: number, bar: string }) => <div />;
1496 *
1497 * // Retrieves the props 'MyComponent' accepts
1498 * type MyComponentPropsWithoutRef = React.ComponentPropsWithoutRef<typeof MyComponent>;
1499 * ```
1500 */
1501 type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
1502
1503 /**
1504 * Retrieves the type of the 'ref' prop for a given component type or tag name.
1505 *
1506 * @template C The component type.
1507 *
1508 * @example
1509 *
1510 * ```tsx
1511 * type MyComponentRef = React.ComponentRef<typeof MyComponent>;
1512 * ```
1513 *
1514 * @example
1515 *
1516 * ```tsx
1517 * type DivRef = React.ComponentRef<'div'>;
1518 * ```
1519 */
1520 type ComponentRef<T extends ElementType> = ComponentPropsWithRef<T> extends RefAttributes<infer Method> ? Method
1521 : never;
1522
1523 // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
1524 // but can be given its own specific name
1525 type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<CustomComponentPropsWithRef<T>> & {
1526 readonly type: T;
1527 };
1528
1529 /**
1530 * Lets you skip re-rendering a component when its props are unchanged.
1531 *
1532 * @see {@link https://react.dev/reference/react/memo React Docs}
1533 *
1534 * @param Component The component to memoize.
1535 * @param propsAreEqual A function that will be used to determine if the props have changed.
1536 *
1537 * @example
1538 *
1539 * ```tsx
1540 * import { memo } from 'react';
1541 *
1542 * const SomeComponent = memo(function SomeComponent(props: { foo: string }) {
1543 * // ...
1544 * });
1545 * ```
1546 */
1547 function memo<P extends object>(
1548 Component: FunctionComponent<P>,
1549 propsAreEqual?: (prevProps: Readonly<P>, nextProps: Readonly<P>) => boolean,
1550 ): NamedExoticComponent<P>;
1551 function memo<T extends ComponentType<any>>(
1552 Component: T,
1553 propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
1554 ): MemoExoticComponent<T>;
1555
1556 interface LazyExoticComponent<T extends ComponentType<any>>
1557 extends ExoticComponent<CustomComponentPropsWithRef<T>>
1558 {
1559 readonly _result: T;
1560 }
1561
1562 /**
1563 * Lets you defer loading a component’s code until it is rendered for the first time.
1564 *
1565 * @see {@link https://react.dev/reference/react/lazy React Docs}
1566 *
1567 * @param load A function that returns a `Promise` or another thenable (a `Promise`-like object with a
1568 * then method). React will not call `load` until the first time you attempt to render the returned
1569 * component. After React first calls load, it will wait for it to resolve, and then render the
1570 * resolved value’s `.default` as a React component. Both the returned `Promise` and the `Promise`’s
1571 * resolved value will be cached, so React will not call load more than once. If the `Promise` rejects,
1572 * React will throw the rejection reason for the nearest Error Boundary to handle.
1573 *
1574 * @example
1575 *
1576 * ```tsx
1577 * import { lazy } from 'react';
1578 *
1579 * const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
1580 * ```
1581 */
1582 function lazy<T extends ComponentType<any>>(
1583 load: () => Promise<{ default: T }>,
1584 ): LazyExoticComponent<T>;
1585
1586 //
1587 // React Hooks
1588 // ----------------------------------------------------------------------
1589
1590 /**
1591 * The instruction passed to a {@link Dispatch} function in {@link useState}
1592 * to tell React what the next value of the {@link useState} should be.
1593 *
1594 * Often found wrapped in {@link Dispatch}.
1595 *
1596 * @template S The type of the state.
1597 *
1598 * @example
1599 *
1600 * ```tsx
1601 * // This return type correctly represents the type of
1602 * // `setCount` in the example below.
1603 * const useCustomState = (): Dispatch<SetStateAction<number>> => {
1604 * const [count, setCount] = useState(0);
1605 *
1606 * return setCount;
1607 * }
1608 * ```
1609 */
1610 type SetStateAction<S> = S | ((prevState: S) => S);
1611
1612 /**
1613 * A function that can be used to update the state of a {@link useState}
1614 * or {@link useReducer} hook.
1615 */
1616 type Dispatch<A> = (value: A) => void;
1617 /**
1618 * A {@link Dispatch} function can sometimes be called without any arguments.
1619 */
1620 type DispatchWithoutAction = () => void;
1621 // Limit the reducer to accept only 0 or 1 action arguments
1622 // eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
1623 type AnyActionArg = [] | [any];
1624 // Get the dispatch type from the reducer arguments (captures optional action argument correctly)
1625 type ActionDispatch<ActionArg extends AnyActionArg> = (...args: ActionArg) => void;
1626 // Unlike redux, the actions _can_ be anything
1627 type Reducer<S, A> = (prevState: S, action: A) => S;
1628 // If useReducer accepts a reducer without action, dispatch may be called without any parameters.
1629 type ReducerWithoutAction<S> = (prevState: S) => S;
1630 // types used to try and prevent the compiler from reducing S
1631 // to a supertype common with the second argument to useReducer()
1632 type ReducerState<R extends Reducer<any, any>> = R extends Reducer<infer S, any> ? S : never;
1633 type DependencyList = readonly unknown[];
1634
1635 // NOTE: callbacks are _only_ allowed to return either void, or a destructor.
1636 type EffectCallback = () => void | Destructor;
1637
1638 /**
1639 * @deprecated Use `RefObject` instead.
1640 */
1641 interface MutableRefObject<T> {
1642 current: T;
1643 }
1644
1645 // This will technically work if you give a Consumer<T> or Provider<T> but it's deprecated and warns
1646 /**
1647 * Accepts a context object (the value returned from `React.createContext`) and returns the current
1648 * context value, as given by the nearest context provider for the given context.
1649 *
1650 * @version 16.8.0
1651 * @see {@link https://react.dev/reference/react/useContext}
1652 */
1653 function useContext<T>(context: Context<T> /*, (not public API) observedBits?: number|boolean */): T;
1654 /**
1655 * Returns a stateful value, and a function to update it.
1656 *
1657 * @version 16.8.0
1658 * @see {@link https://react.dev/reference/react/useState}
1659 */
1660 function useState<S>(initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
1661 // convenience overload when first argument is omitted
1662 /**
1663 * Returns a stateful value, and a function to update it.
1664 *
1665 * @version 16.8.0
1666 * @see {@link https://react.dev/reference/react/useState}
1667 */
1668 function useState<S = undefined>(): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
1669 /**
1670 * An alternative to `useState`.
1671 *
1672 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1673 * multiple sub-values. It also lets you optimize performance for components that trigger deep
1674 * updates because you can pass `dispatch` down instead of callbacks.
1675 *
1676 * @version 16.8.0
1677 * @see {@link https://react.dev/reference/react/useReducer}
1678 */
1679 function useReducer<S, A extends AnyActionArg>(
1680 reducer: (prevState: S, ...args: A) => S,
1681 initialState: S,
1682 ): [S, ActionDispatch<A>];
1683 /**
1684 * An alternative to `useState`.
1685 *
1686 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1687 * multiple sub-values. It also lets you optimize performance for components that trigger deep
1688 * updates because you can pass `dispatch` down instead of callbacks.
1689 *
1690 * @version 16.8.0
1691 * @see {@link https://react.dev/reference/react/useReducer}
1692 */
1693 function useReducer<S, A extends AnyActionArg>(
1694 reducer: (prevState: S, ...args: A) => S,
1695 initialState: S,
1696 ): [S, ActionDispatch<A>];
1697 /**
1698 * An alternative to `useState`.
1699 *
1700 * `useReducer` is usually preferable to `useState` when you have complex state logic that involves
1701 * multiple sub-values. It also lets you optimize performance for components that trigger deep
1702 * updates because you can pass `dispatch` down instead of callbacks.
1703 *
1704 * @version 16.8.0
1705 * @see {@link https://react.dev/reference/react/useReducer}
1706 */
1707 function useReducer<S, I, A extends AnyActionArg>(
1708 reducer: (prevState: S, ...args: A) => S,
1709 initialArg: I,
1710 init: (i: I) => S,
1711 ): [S, ActionDispatch<A>];
1712 /**
1713 * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1714 * (`initialValue`). The returned object will persist for the full lifetime of the component.
1715 *
1716 * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1717 * value around similar to how you’d use instance fields in classes.
1718 *
1719 * @version 16.8.0
1720 * @see {@link https://react.dev/reference/react/useRef}
1721 */
1722 function useRef<T>(initialValue: T): RefObject<T>;
1723 // convenience overload for refs given as a ref prop as they typically start with a null value
1724 /**
1725 * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1726 * (`initialValue`). The returned object will persist for the full lifetime of the component.
1727 *
1728 * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1729 * value around similar to how you’d use instance fields in classes.
1730 *
1731 * @version 16.8.0
1732 * @see {@link https://react.dev/reference/react/useRef}
1733 */
1734 function useRef<T>(initialValue: T | null): RefObject<T | null>;
1735 // convenience overload for undefined initialValue
1736 /**
1737 * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
1738 * (`initialValue`). The returned object will persist for the full lifetime of the component.
1739 *
1740 * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
1741 * value around similar to how you’d use instance fields in classes.
1742 *
1743 * @version 16.8.0
1744 * @see {@link https://react.dev/reference/react/useRef}
1745 */
1746 function useRef<T>(initialValue: T | undefined): RefObject<T | undefined>;
1747 /**
1748 * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
1749 * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside
1750 * `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint.
1751 *
1752 * Prefer the standard `useEffect` when possible to avoid blocking visual updates.
1753 *
1754 * If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as
1755 * `componentDidMount` and `componentDidUpdate`.
1756 *
1757 * @version 16.8.0
1758 * @see {@link https://react.dev/reference/react/useLayoutEffect}
1759 */
1760 function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;
1761 /**
1762 * Accepts a function that contains imperative, possibly effectful code.
1763 *
1764 * @param effect Imperative function that can return a cleanup function
1765 * @param deps If present, effect will only activate if the values in the list change.
1766 *
1767 * @version 16.8.0
1768 * @see {@link https://react.dev/reference/react/useEffect}
1769 */
1770 function useEffect(effect: EffectCallback, deps?: DependencyList): void;
1771 // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref<T>
1772 /**
1773 * `useImperativeHandle` customizes the instance value that is exposed to parent components when using
1774 * `ref`. As always, imperative code using refs should be avoided in most cases.
1775 *
1776 * `useImperativeHandle` should be used with `React.forwardRef`.
1777 *
1778 * @version 16.8.0
1779 * @see {@link https://react.dev/reference/react/useImperativeHandle}
1780 */
1781 function useImperativeHandle<T, R extends T>(ref: Ref<T> | undefined, init: () => R, deps?: DependencyList): void;
1782 // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key
1783 // useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y.
1784 /**
1785 * `useCallback` will return a memoized version of the callback that only changes if one of the `inputs`
1786 * has changed.
1787 *
1788 * @version 16.8.0
1789 * @see {@link https://react.dev/reference/react/useCallback}
1790 */
1791 // A specific function type would not trigger implicit any.
1792 // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.
1793 // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1794 function useCallback<T extends Function>(callback: T, deps: DependencyList): T;
1795 /**
1796 * `useMemo` will only recompute the memoized value when one of the `deps` has changed.
1797 *
1798 * @version 16.8.0
1799 * @see {@link https://react.dev/reference/react/useMemo}
1800 */
1801 // allow undefined, but don't make it optional as that is very likely a mistake
1802 function useMemo<T>(factory: () => T, deps: DependencyList): T;
1803 /**
1804 * `useDebugValue` can be used to display a label for custom hooks in React DevTools.
1805 *
1806 * NOTE: We don’t recommend adding debug values to every custom hook.
1807 * It’s most valuable for custom hooks that are part of shared libraries.
1808 *
1809 * @version 16.8.0
1810 * @see {@link https://react.dev/reference/react/useDebugValue}
1811 */
1812 // the name of the custom hook is itself derived from the function name at runtime:
1813 // it's just the function name without the "use" prefix.
1814 function useDebugValue<T>(value: T, format?: (value: T) => any): void;
1815
1816 export type TransitionFunction = () => VoidOrUndefinedOnly | Promise<VoidOrUndefinedOnly>;
1817 // strange definition to allow vscode to show documentation on the invocation
1818 export interface TransitionStartFunction {
1819 /**
1820 * State updates caused inside the callback are allowed to be deferred.
1821 *
1822 * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
1823 *
1824 * @param callback A function which causes state updates that can be deferred.
1825 */
1826 (callback: TransitionFunction): void;
1827 }
1828
1829 /**
1830 * Returns a deferred version of the value that may “lag behind” it.
1831 *
1832 * This is commonly used to keep the interface responsive when you have something that renders immediately
1833 * based on user input and something that needs to wait for a data fetch.
1834 *
1835 * A good example of this is a text input.
1836 *
1837 * @param value The value that is going to be deferred
1838 * @param initialValue A value to use during the initial render of a component. If this option is omitted, `useDeferredValue` will not defer during the initial render, because there’s no previous version of `value` that it can render instead.
1839 *
1840 * @see {@link https://react.dev/reference/react/useDeferredValue}
1841 */
1842 export function useDeferredValue<T>(value: T, initialValue?: T): T;
1843
1844 /**
1845 * Allows components to avoid undesirable loading states by waiting for content to load
1846 * before transitioning to the next screen. It also allows components to defer slower,
1847 * data fetching updates until subsequent renders so that more crucial updates can be
1848 * rendered immediately.
1849 *
1850 * The `useTransition` hook returns two values in an array.
1851 *
1852 * The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish.
1853 * The second is a function that takes a callback. We can use it to tell React which state we want to defer.
1854 *
1855 * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
1856 *
1857 * @see {@link https://react.dev/reference/react/useTransition}
1858 */
1859 export function useTransition(): [boolean, TransitionStartFunction];
1860
1861 /**
1862 * Similar to `useTransition` but allows uses where hooks are not available.
1863 *
1864 * @param callback A function which causes state updates that can be deferred.
1865 */
1866 export function startTransition(scope: TransitionFunction): void;
1867
1868 /**
1869 * Wrap any code rendering and triggering updates to your components into `act()` calls.
1870 *
1871 * Ensures that the behavior in your tests matches what happens in the browser
1872 * more closely by executing pending `useEffect`s before returning. This also
1873 * reduces the amount of re-renders done.
1874 *
1875 * @param callback A synchronous, void callback that will execute as a single, complete React commit.
1876 *
1877 * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
1878 */
1879 // NOTES
1880 // - the order of these signatures matters - typescript will check the signatures in source order.
1881 // If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
1882 // `strictNullChecks: false`.
1883 // - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
1884 // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
1885 export function act(callback: () => VoidOrUndefinedOnly): void;
1886 export function act<T>(callback: () => T | Promise<T>): Promise<T>;
1887
1888 export function useId(): string;
1889
1890 /**
1891 * @param effect Imperative function that can return a cleanup function
1892 * @param deps If present, effect will only activate if the values in the list change.
1893 *
1894 * @see {@link https://github.com/facebook/react/pull/21913}
1895 */
1896 export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void;
1897
1898 /**
1899 * @param subscribe
1900 * @param getSnapshot
1901 *
1902 * @see {@link https://github.com/reactwg/react-18/discussions/86}
1903 */
1904 // keep in sync with `useSyncExternalStore` from `use-sync-external-store`
1905 export function useSyncExternalStore<Snapshot>(
1906 subscribe: (onStoreChange: () => void) => () => void,
1907 getSnapshot: () => Snapshot,
1908 getServerSnapshot?: () => Snapshot,
1909 ): Snapshot;
1910
1911 export function useOptimistic<State>(
1912 passthrough: State,
1913 ): [State, (action: State | ((pendingState: State) => State)) => void];
1914 export function useOptimistic<State, Action>(
1915 passthrough: State,
1916 reducer: (state: State, action: Action) => State,
1917 ): [State, (action: Action) => void];
1918
1919 export type Usable<T> = PromiseLike<T> | Context<T>;
1920
1921 export function use<T>(usable: Usable<T>): T;
1922
1923 export function useActionState<State>(
1924 action: (state: Awaited<State>) => State | Promise<State>,
1925 initialState: Awaited<State>,
1926 permalink?: string,
1927 ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
1928 export function useActionState<State, Payload>(
1929 action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
1930 initialState: Awaited<State>,
1931 permalink?: string,
1932 ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1933
1934 // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1935 export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
1936
1937 //
1938 // Event System
1939 // ----------------------------------------------------------------------
1940 // TODO: change any to unknown when moving to TS v3
1941 interface BaseSyntheticEvent<E = object, C = any, T = any> {
1942 nativeEvent: E;
1943 currentTarget: C;
1944 target: T;
1945 bubbles: boolean;
1946 cancelable: boolean;
1947 defaultPrevented: boolean;
1948 eventPhase: number;
1949 isTrusted: boolean;
1950 preventDefault(): void;
1951 isDefaultPrevented(): boolean;
1952 stopPropagation(): void;
1953 isPropagationStopped(): boolean;
1954 persist(): void;
1955 timeStamp: number;
1956 type: string;
1957 }
1958
1959 /**
1960 * currentTarget - a reference to the element on which the event listener is registered.
1961 *
1962 * target - a reference to the element from which the event was originally dispatched.
1963 * This might be a child element to the element on which the event listener is registered.
1964 * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
1965 */
1966 interface SyntheticEvent<T = Element, E = Event> extends BaseSyntheticEvent<E, EventTarget & T, EventTarget> {}
1967
1968 interface ClipboardEvent<T = Element> extends SyntheticEvent<T, NativeClipboardEvent> {
1969 clipboardData: DataTransfer;
1970 }
1971
1972 interface CompositionEvent<T = Element> extends SyntheticEvent<T, NativeCompositionEvent> {
1973 data: string;
1974 }
1975
1976 interface DragEvent<T = Element> extends MouseEvent<T, NativeDragEvent> {
1977 dataTransfer: DataTransfer;
1978 }
1979
1980 interface PointerEvent<T = Element> extends MouseEvent<T, NativePointerEvent> {
1981 pointerId: number;
1982 pressure: number;
1983 tangentialPressure: number;
1984 tiltX: number;
1985 tiltY: number;
1986 twist: number;
1987 width: number;
1988 height: number;
1989 pointerType: "mouse" | "pen" | "touch";
1990 isPrimary: boolean;
1991 }
1992
1993 interface FocusEvent<Target = Element, RelatedTarget = Element> extends SyntheticEvent<Target, NativeFocusEvent> {
1994 relatedTarget: (EventTarget & RelatedTarget) | null;
1995 target: EventTarget & Target;
1996 }
1997
1998 interface FormEvent<T = Element> extends SyntheticEvent<T> {
1999 }
2000
2001 interface InvalidEvent<T = Element> extends SyntheticEvent<T> {
2002 target: EventTarget & T;
2003 }
2004
2005 interface ChangeEvent<T = Element> extends SyntheticEvent<T> {
2006 target: EventTarget & T;
2007 }
2008
2009 export type ModifierKey =
2010 | "Alt"
2011 | "AltGraph"
2012 | "CapsLock"
2013 | "Control"
2014 | "Fn"
2015 | "FnLock"
2016 | "Hyper"
2017 | "Meta"
2018 | "NumLock"
2019 | "ScrollLock"
2020 | "Shift"
2021 | "Super"
2022 | "Symbol"
2023 | "SymbolLock";
2024
2025 interface KeyboardEvent<T = Element> extends UIEvent<T, NativeKeyboardEvent> {
2026 altKey: boolean;
2027 /** @deprecated */
2028 charCode: number;
2029 ctrlKey: boolean;
2030 code: string;
2031 /**
2032 * 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.
2033 */
2034 getModifierState(key: ModifierKey): boolean;
2035 /**
2036 * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values
2037 */
2038 key: string;
2039 /** @deprecated */
2040 keyCode: number;
2041 locale: string;
2042 location: number;
2043 metaKey: boolean;
2044 repeat: boolean;
2045 shiftKey: boolean;
2046 /** @deprecated */
2047 which: number;
2048 }
2049
2050 interface MouseEvent<T = Element, E = NativeMouseEvent> extends UIEvent<T, E> {
2051 altKey: boolean;
2052 button: number;
2053 buttons: number;
2054 clientX: number;
2055 clientY: number;
2056 ctrlKey: boolean;
2057 /**
2058 * 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.
2059 */
2060 getModifierState(key: ModifierKey): boolean;
2061 metaKey: boolean;
2062 movementX: number;
2063 movementY: number;
2064 pageX: number;
2065 pageY: number;
2066 relatedTarget: EventTarget | null;
2067 screenX: number;
2068 screenY: number;
2069 shiftKey: boolean;
2070 }
2071
2072 interface TouchEvent<T = Element> extends UIEvent<T, NativeTouchEvent> {
2073 altKey: boolean;
2074 changedTouches: TouchList;
2075 ctrlKey: boolean;
2076 /**
2077 * 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.
2078 */
2079 getModifierState(key: ModifierKey): boolean;
2080 metaKey: boolean;
2081 shiftKey: boolean;
2082 targetTouches: TouchList;
2083 touches: TouchList;
2084 }
2085
2086 interface UIEvent<T = Element, E = NativeUIEvent> extends SyntheticEvent<T, E> {
2087 detail: number;
2088 view: AbstractView;
2089 }
2090
2091 interface WheelEvent<T = Element> extends MouseEvent<T, NativeWheelEvent> {
2092 deltaMode: number;
2093 deltaX: number;
2094 deltaY: number;
2095 deltaZ: number;
2096 }
2097
2098 interface AnimationEvent<T = Element> extends SyntheticEvent<T, NativeAnimationEvent> {
2099 animationName: string;
2100 elapsedTime: number;
2101 pseudoElement: string;
2102 }
2103
2104 interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
2105 oldState: "closed" | "open";
2106 newState: "closed" | "open";
2107 }
2108
2109 interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
2110 elapsedTime: number;
2111 propertyName: string;
2112 pseudoElement: string;
2113 }
2114
2115 //
2116 // Event Handler Types
2117 // ----------------------------------------------------------------------
2118
2119 type EventHandler<E extends SyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"];
2120
2121 type ReactEventHandler<T = Element> = EventHandler<SyntheticEvent<T>>;
2122
2123 type ClipboardEventHandler<T = Element> = EventHandler<ClipboardEvent<T>>;
2124 type CompositionEventHandler<T = Element> = EventHandler<CompositionEvent<T>>;
2125 type DragEventHandler<T = Element> = EventHandler<DragEvent<T>>;
2126 type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
2127 type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
2128 type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
2129 type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
2130 type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
2131 type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
2132 type PointerEventHandler<T = Element> = EventHandler<PointerEvent<T>>;
2133 type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
2134 type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
2135 type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
2136 type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
2137 type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
2138
2139 //
2140 // Props / DOM Attributes
2141 // ----------------------------------------------------------------------
2142
2143 interface HTMLProps<T> extends AllHTMLAttributes<T>, ClassAttributes<T> {
2144 }
2145
2146 type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = ClassAttributes<T> & E;
2147
2148 interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
2149 }
2150
2151 interface SVGLineElementAttributes<T> extends SVGProps<T> {}
2152 interface SVGTextElementAttributes<T> extends SVGProps<T> {}
2153
2154 interface DOMAttributes<T> {
2155 children?: ReactNode | undefined;
2156 dangerouslySetInnerHTML?: {
2157 // Should be InnerHTML['innerHTML'].
2158 // But unfortunately we're mixing renderer-specific type declarations.
2159 __html: string | TrustedHTML;
2160 } | undefined;
2161
2162 // Clipboard Events
2163 onCopy?: ClipboardEventHandler<T> | undefined;
2164 onCopyCapture?: ClipboardEventHandler<T> | undefined;
2165 onCut?: ClipboardEventHandler<T> | undefined;
2166 onCutCapture?: ClipboardEventHandler<T> | undefined;
2167 onPaste?: ClipboardEventHandler<T> | undefined;
2168 onPasteCapture?: ClipboardEventHandler<T> | undefined;
2169
2170 // Composition Events
2171 onCompositionEnd?: CompositionEventHandler<T> | undefined;
2172 onCompositionEndCapture?: CompositionEventHandler<T> | undefined;
2173 onCompositionStart?: CompositionEventHandler<T> | undefined;
2174 onCompositionStartCapture?: CompositionEventHandler<T> | undefined;
2175 onCompositionUpdate?: CompositionEventHandler<T> | undefined;
2176 onCompositionUpdateCapture?: CompositionEventHandler<T> | undefined;
2177
2178 // Focus Events
2179 onFocus?: FocusEventHandler<T> | undefined;
2180 onFocusCapture?: FocusEventHandler<T> | undefined;
2181 onBlur?: FocusEventHandler<T> | undefined;
2182 onBlurCapture?: FocusEventHandler<T> | undefined;
2183
2184 // Form Events
2185 onChange?: FormEventHandler<T> | undefined;
2186 onChangeCapture?: FormEventHandler<T> | undefined;
2187 onBeforeInput?: FormEventHandler<T> | undefined;
2188 onBeforeInputCapture?: FormEventHandler<T> | undefined;
2189 onInput?: FormEventHandler<T> | undefined;
2190 onInputCapture?: FormEventHandler<T> | undefined;
2191 onReset?: FormEventHandler<T> | undefined;
2192 onResetCapture?: FormEventHandler<T> | undefined;
2193 onSubmit?: FormEventHandler<T> | undefined;
2194 onSubmitCapture?: FormEventHandler<T> | undefined;
2195 onInvalid?: FormEventHandler<T> | undefined;
2196 onInvalidCapture?: FormEventHandler<T> | undefined;
2197
2198 // Image Events
2199 onLoad?: ReactEventHandler<T> | undefined;
2200 onLoadCapture?: ReactEventHandler<T> | undefined;
2201 onError?: ReactEventHandler<T> | undefined; // also a Media Event
2202 onErrorCapture?: ReactEventHandler<T> | undefined; // also a Media Event
2203
2204 // Keyboard Events
2205 onKeyDown?: KeyboardEventHandler<T> | undefined;
2206 onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
2207 /** @deprecated Use `onKeyUp` or `onKeyDown` instead */
2208 onKeyPress?: KeyboardEventHandler<T> | undefined;
2209 /** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
2210 onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
2211 onKeyUp?: KeyboardEventHandler<T> | undefined;
2212 onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
2213
2214 // Media Events
2215 onAbort?: ReactEventHandler<T> | undefined;
2216 onAbortCapture?: ReactEventHandler<T> | undefined;
2217 onCanPlay?: ReactEventHandler<T> | undefined;
2218 onCanPlayCapture?: ReactEventHandler<T> | undefined;
2219 onCanPlayThrough?: ReactEventHandler<T> | undefined;
2220 onCanPlayThroughCapture?: ReactEventHandler<T> | undefined;
2221 onDurationChange?: ReactEventHandler<T> | undefined;
2222 onDurationChangeCapture?: ReactEventHandler<T> | undefined;
2223 onEmptied?: ReactEventHandler<T> | undefined;
2224 onEmptiedCapture?: ReactEventHandler<T> | undefined;
2225 onEncrypted?: ReactEventHandler<T> | undefined;
2226 onEncryptedCapture?: ReactEventHandler<T> | undefined;
2227 onEnded?: ReactEventHandler<T> | undefined;
2228 onEndedCapture?: ReactEventHandler<T> | undefined;
2229 onLoadedData?: ReactEventHandler<T> | undefined;
2230 onLoadedDataCapture?: ReactEventHandler<T> | undefined;
2231 onLoadedMetadata?: ReactEventHandler<T> | undefined;
2232 onLoadedMetadataCapture?: ReactEventHandler<T> | undefined;
2233 onLoadStart?: ReactEventHandler<T> | undefined;
2234 onLoadStartCapture?: ReactEventHandler<T> | undefined;
2235 onPause?: ReactEventHandler<T> | undefined;
2236 onPauseCapture?: ReactEventHandler<T> | undefined;
2237 onPlay?: ReactEventHandler<T> | undefined;
2238 onPlayCapture?: ReactEventHandler<T> | undefined;
2239 onPlaying?: ReactEventHandler<T> | undefined;
2240 onPlayingCapture?: ReactEventHandler<T> | undefined;
2241 onProgress?: ReactEventHandler<T> | undefined;
2242 onProgressCapture?: ReactEventHandler<T> | undefined;
2243 onRateChange?: ReactEventHandler<T> | undefined;
2244 onRateChangeCapture?: ReactEventHandler<T> | undefined;
2245 onResize?: ReactEventHandler<T> | undefined;
2246 onResizeCapture?: ReactEventHandler<T> | undefined;
2247 onSeeked?: ReactEventHandler<T> | undefined;
2248 onSeekedCapture?: ReactEventHandler<T> | undefined;
2249 onSeeking?: ReactEventHandler<T> | undefined;
2250 onSeekingCapture?: ReactEventHandler<T> | undefined;
2251 onStalled?: ReactEventHandler<T> | undefined;
2252 onStalledCapture?: ReactEventHandler<T> | undefined;
2253 onSuspend?: ReactEventHandler<T> | undefined;
2254 onSuspendCapture?: ReactEventHandler<T> | undefined;
2255 onTimeUpdate?: ReactEventHandler<T> | undefined;
2256 onTimeUpdateCapture?: ReactEventHandler<T> | undefined;
2257 onVolumeChange?: ReactEventHandler<T> | undefined;
2258 onVolumeChangeCapture?: ReactEventHandler<T> | undefined;
2259 onWaiting?: ReactEventHandler<T> | undefined;
2260 onWaitingCapture?: ReactEventHandler<T> | undefined;
2261
2262 // MouseEvents
2263 onAuxClick?: MouseEventHandler<T> | undefined;
2264 onAuxClickCapture?: MouseEventHandler<T> | undefined;
2265 onClick?: MouseEventHandler<T> | undefined;
2266 onClickCapture?: MouseEventHandler<T> | undefined;
2267 onContextMenu?: MouseEventHandler<T> | undefined;
2268 onContextMenuCapture?: MouseEventHandler<T> | undefined;
2269 onDoubleClick?: MouseEventHandler<T> | undefined;
2270 onDoubleClickCapture?: MouseEventHandler<T> | undefined;
2271 onDrag?: DragEventHandler<T> | undefined;
2272 onDragCapture?: DragEventHandler<T> | undefined;
2273 onDragEnd?: DragEventHandler<T> | undefined;
2274 onDragEndCapture?: DragEventHandler<T> | undefined;
2275 onDragEnter?: DragEventHandler<T> | undefined;
2276 onDragEnterCapture?: DragEventHandler<T> | undefined;
2277 onDragExit?: DragEventHandler<T> | undefined;
2278 onDragExitCapture?: DragEventHandler<T> | undefined;
2279 onDragLeave?: DragEventHandler<T> | undefined;
2280 onDragLeaveCapture?: DragEventHandler<T> | undefined;
2281 onDragOver?: DragEventHandler<T> | undefined;
2282 onDragOverCapture?: DragEventHandler<T> | undefined;
2283 onDragStart?: DragEventHandler<T> | undefined;
2284 onDragStartCapture?: DragEventHandler<T> | undefined;
2285 onDrop?: DragEventHandler<T> | undefined;
2286 onDropCapture?: DragEventHandler<T> | undefined;
2287 onMouseDown?: MouseEventHandler<T> | undefined;
2288 onMouseDownCapture?: MouseEventHandler<T> | undefined;
2289 onMouseEnter?: MouseEventHandler<T> | undefined;
2290 onMouseLeave?: MouseEventHandler<T> | undefined;
2291 onMouseMove?: MouseEventHandler<T> | undefined;
2292 onMouseMoveCapture?: MouseEventHandler<T> | undefined;
2293 onMouseOut?: MouseEventHandler<T> | undefined;
2294 onMouseOutCapture?: MouseEventHandler<T> | undefined;
2295 onMouseOver?: MouseEventHandler<T> | undefined;
2296 onMouseOverCapture?: MouseEventHandler<T> | undefined;
2297 onMouseUp?: MouseEventHandler<T> | undefined;
2298 onMouseUpCapture?: MouseEventHandler<T> | undefined;
2299
2300 // Selection Events
2301 onSelect?: ReactEventHandler<T> | undefined;
2302 onSelectCapture?: ReactEventHandler<T> | undefined;
2303
2304 // Touch Events
2305 onTouchCancel?: TouchEventHandler<T> | undefined;
2306 onTouchCancelCapture?: TouchEventHandler<T> | undefined;
2307 onTouchEnd?: TouchEventHandler<T> | undefined;
2308 onTouchEndCapture?: TouchEventHandler<T> | undefined;
2309 onTouchMove?: TouchEventHandler<T> | undefined;
2310 onTouchMoveCapture?: TouchEventHandler<T> | undefined;
2311 onTouchStart?: TouchEventHandler<T> | undefined;
2312 onTouchStartCapture?: TouchEventHandler<T> | undefined;
2313
2314 // Pointer Events
2315 onPointerDown?: PointerEventHandler<T> | undefined;
2316 onPointerDownCapture?: PointerEventHandler<T> | undefined;
2317 onPointerMove?: PointerEventHandler<T> | undefined;
2318 onPointerMoveCapture?: PointerEventHandler<T> | undefined;
2319 onPointerUp?: PointerEventHandler<T> | undefined;
2320 onPointerUpCapture?: PointerEventHandler<T> | undefined;
2321 onPointerCancel?: PointerEventHandler<T> | undefined;
2322 onPointerCancelCapture?: PointerEventHandler<T> | undefined;
2323 onPointerEnter?: PointerEventHandler<T> | undefined;
2324 onPointerLeave?: PointerEventHandler<T> | undefined;
2325 onPointerOver?: PointerEventHandler<T> | undefined;
2326 onPointerOverCapture?: PointerEventHandler<T> | undefined;
2327 onPointerOut?: PointerEventHandler<T> | undefined;
2328 onPointerOutCapture?: PointerEventHandler<T> | undefined;
2329 onGotPointerCapture?: PointerEventHandler<T> | undefined;
2330 onGotPointerCaptureCapture?: PointerEventHandler<T> | undefined;
2331 onLostPointerCapture?: PointerEventHandler<T> | undefined;
2332 onLostPointerCaptureCapture?: PointerEventHandler<T> | undefined;
2333
2334 // UI Events
2335 onScroll?: UIEventHandler<T> | undefined;
2336 onScrollCapture?: UIEventHandler<T> | undefined;
2337
2338 // Wheel Events
2339 onWheel?: WheelEventHandler<T> | undefined;
2340 onWheelCapture?: WheelEventHandler<T> | undefined;
2341
2342 // Animation Events
2343 onAnimationStart?: AnimationEventHandler<T> | undefined;
2344 onAnimationStartCapture?: AnimationEventHandler<T> | undefined;
2345 onAnimationEnd?: AnimationEventHandler<T> | undefined;
2346 onAnimationEndCapture?: AnimationEventHandler<T> | undefined;
2347 onAnimationIteration?: AnimationEventHandler<T> | undefined;
2348 onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
2349
2350 // Toggle Events
2351 onToggle?: ToggleEventHandler<T> | undefined;
2352 onBeforeToggle?: ToggleEventHandler<T> | undefined;
2353
2354 // Transition Events
2355 onTransitionCancel?: TransitionEventHandler<T> | undefined;
2356 onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
2357 onTransitionEnd?: TransitionEventHandler<T> | undefined;
2358 onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
2359 onTransitionRun?: TransitionEventHandler<T> | undefined;
2360 onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
2361 onTransitionStart?: TransitionEventHandler<T> | undefined;
2362 onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
2363 }
2364
2365 export interface CSSProperties extends CSS.Properties<string | number> {
2366 /**
2367 * The index signature was removed to enable closed typing for style
2368 * using CSSType. You're able to use type assertion or module augmentation
2369 * to add properties or an index signature of your own.
2370 *
2371 * For examples and more information, visit:
2372 * https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
2373 */
2374 }
2375
2376 // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
2377 interface AriaAttributes {
2378 /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
2379 "aria-activedescendant"?: string | undefined;
2380 /** 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. */
2381 "aria-atomic"?: Booleanish | undefined;
2382 /**
2383 * 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
2384 * presented if they are made.
2385 */
2386 "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
2387 /** 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. */
2388 /**
2389 * Defines a string value that labels the current element, which is intended to be converted into Braille.
2390 * @see aria-label.
2391 */
2392 "aria-braillelabel"?: string | undefined;
2393 /**
2394 * Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
2395 * @see aria-roledescription.
2396 */
2397 "aria-brailleroledescription"?: string | undefined;
2398 "aria-busy"?: Booleanish | undefined;
2399 /**
2400 * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
2401 * @see aria-pressed @see aria-selected.
2402 */
2403 "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
2404 /**
2405 * Defines the total number of columns in a table, grid, or treegrid.
2406 * @see aria-colindex.
2407 */
2408 "aria-colcount"?: number | undefined;
2409 /**
2410 * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
2411 * @see aria-colcount @see aria-colspan.
2412 */
2413 "aria-colindex"?: number | undefined;
2414 /**
2415 * Defines a human readable text alternative of aria-colindex.
2416 * @see aria-rowindextext.
2417 */
2418 "aria-colindextext"?: string | undefined;
2419 /**
2420 * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
2421 * @see aria-colindex @see aria-rowspan.
2422 */
2423 "aria-colspan"?: number | undefined;
2424 /**
2425 * Identifies the element (or elements) whose contents or presence are controlled by the current element.
2426 * @see aria-owns.
2427 */
2428 "aria-controls"?: string | undefined;
2429 /** Indicates the element that represents the current item within a container or set of related elements. */
2430 "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
2431 /**
2432 * Identifies the element (or elements) that describes the object.
2433 * @see aria-labelledby
2434 */
2435 "aria-describedby"?: string | undefined;
2436 /**
2437 * Defines a string value that describes or annotates the current element.
2438 * @see related aria-describedby.
2439 */
2440 "aria-description"?: string | undefined;
2441 /**
2442 * Identifies the element that provides a detailed, extended description for the object.
2443 * @see aria-describedby.
2444 */
2445 "aria-details"?: string | undefined;
2446 /**
2447 * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
2448 * @see aria-hidden @see aria-readonly.
2449 */
2450 "aria-disabled"?: Booleanish | undefined;
2451 /**
2452 * Indicates what functions can be performed when a dragged object is released on the drop target.
2453 * @deprecated in ARIA 1.1
2454 */
2455 "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
2456 /**
2457 * Identifies the element that provides an error message for the object.
2458 * @see aria-invalid @see aria-describedby.
2459 */
2460 "aria-errormessage"?: string | undefined;
2461 /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
2462 "aria-expanded"?: Booleanish | undefined;
2463 /**
2464 * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
2465 * allows assistive technology to override the general default of reading in document source order.
2466 */
2467 "aria-flowto"?: string | undefined;
2468 /**
2469 * Indicates an element's "grabbed" state in a drag-and-drop operation.
2470 * @deprecated in ARIA 1.1
2471 */
2472 "aria-grabbed"?: Booleanish | undefined;
2473 /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
2474 "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
2475 /**
2476 * Indicates whether the element is exposed to an accessibility API.
2477 * @see aria-disabled.
2478 */
2479 "aria-hidden"?: Booleanish | undefined;
2480 /**
2481 * Indicates the entered value does not conform to the format expected by the application.
2482 * @see aria-errormessage.
2483 */
2484 "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
2485 /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
2486 "aria-keyshortcuts"?: string | undefined;
2487 /**
2488 * Defines a string value that labels the current element.
2489 * @see aria-labelledby.
2490 */
2491 "aria-label"?: string | undefined;
2492 /**
2493 * Identifies the element (or elements) that labels the current element.
2494 * @see aria-describedby.
2495 */
2496 "aria-labelledby"?: string | undefined;
2497 /** Defines the hierarchical level of an element within a structure. */
2498 "aria-level"?: number | undefined;
2499 /** 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. */
2500 "aria-live"?: "off" | "assertive" | "polite" | undefined;
2501 /** Indicates whether an element is modal when displayed. */
2502 "aria-modal"?: Booleanish | undefined;
2503 /** Indicates whether a text box accepts multiple lines of input or only a single line. */
2504 "aria-multiline"?: Booleanish | undefined;
2505 /** Indicates that the user may select more than one item from the current selectable descendants. */
2506 "aria-multiselectable"?: Booleanish | undefined;
2507 /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
2508 "aria-orientation"?: "horizontal" | "vertical" | undefined;
2509 /**
2510 * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
2511 * between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
2512 * @see aria-controls.
2513 */
2514 "aria-owns"?: string | undefined;
2515 /**
2516 * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
2517 * A hint could be a sample value or a brief description of the expected format.
2518 */
2519 "aria-placeholder"?: string | undefined;
2520 /**
2521 * 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.
2522 * @see aria-setsize.
2523 */
2524 "aria-posinset"?: number | undefined;
2525 /**
2526 * Indicates the current "pressed" state of toggle buttons.
2527 * @see aria-checked @see aria-selected.
2528 */
2529 "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
2530 /**
2531 * Indicates that the element is not editable, but is otherwise operable.
2532 * @see aria-disabled.
2533 */
2534 "aria-readonly"?: Booleanish | undefined;
2535 /**
2536 * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
2537 * @see aria-atomic.
2538 */
2539 "aria-relevant"?:
2540 | "additions"
2541 | "additions removals"
2542 | "additions text"
2543 | "all"
2544 | "removals"
2545 | "removals additions"
2546 | "removals text"
2547 | "text"
2548 | "text additions"
2549 | "text removals"
2550 | undefined;
2551 /** Indicates that user input is required on the element before a form may be submitted. */
2552 "aria-required"?: Booleanish | undefined;
2553 /** Defines a human-readable, author-localized description for the role of an element. */
2554 "aria-roledescription"?: string | undefined;
2555 /**
2556 * Defines the total number of rows in a table, grid, or treegrid.
2557 * @see aria-rowindex.
2558 */
2559 "aria-rowcount"?: number | undefined;
2560 /**
2561 * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
2562 * @see aria-rowcount @see aria-rowspan.
2563 */
2564 "aria-rowindex"?: number | undefined;
2565 /**
2566 * Defines a human readable text alternative of aria-rowindex.
2567 * @see aria-colindextext.
2568 */
2569 "aria-rowindextext"?: string | undefined;
2570 /**
2571 * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
2572 * @see aria-rowindex @see aria-colspan.
2573 */
2574 "aria-rowspan"?: number | undefined;
2575 /**
2576 * Indicates the current "selected" state of various widgets.
2577 * @see aria-checked @see aria-pressed.
2578 */
2579 "aria-selected"?: Booleanish | undefined;
2580 /**
2581 * 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.
2582 * @see aria-posinset.
2583 */
2584 "aria-setsize"?: number | undefined;
2585 /** Indicates if items in a table or grid are sorted in ascending or descending order. */
2586 "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
2587 /** Defines the maximum allowed value for a range widget. */
2588 "aria-valuemax"?: number | undefined;
2589 /** Defines the minimum allowed value for a range widget. */
2590 "aria-valuemin"?: number | undefined;
2591 /**
2592 * Defines the current value for a range widget.
2593 * @see aria-valuetext.
2594 */
2595 "aria-valuenow"?: number | undefined;
2596 /** Defines the human readable text alternative of aria-valuenow for a range widget. */
2597 "aria-valuetext"?: string | undefined;
2598 }
2599
2600 // All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
2601 type AriaRole =
2602 | "alert"
2603 | "alertdialog"
2604 | "application"
2605 | "article"
2606 | "banner"
2607 | "button"
2608 | "cell"
2609 | "checkbox"
2610 | "columnheader"
2611 | "combobox"
2612 | "complementary"
2613 | "contentinfo"
2614 | "definition"
2615 | "dialog"
2616 | "directory"
2617 | "document"
2618 | "feed"
2619 | "figure"
2620 | "form"
2621 | "grid"
2622 | "gridcell"
2623 | "group"
2624 | "heading"
2625 | "img"
2626 | "link"
2627 | "list"
2628 | "listbox"
2629 | "listitem"
2630 | "log"
2631 | "main"
2632 | "marquee"
2633 | "math"
2634 | "menu"
2635 | "menubar"
2636 | "menuitem"
2637 | "menuitemcheckbox"
2638 | "menuitemradio"
2639 | "navigation"
2640 | "none"
2641 | "note"
2642 | "option"
2643 | "presentation"
2644 | "progressbar"
2645 | "radio"
2646 | "radiogroup"
2647 | "region"
2648 | "row"
2649 | "rowgroup"
2650 | "rowheader"
2651 | "scrollbar"
2652 | "search"
2653 | "searchbox"
2654 | "separator"
2655 | "slider"
2656 | "spinbutton"
2657 | "status"
2658 | "switch"
2659 | "tab"
2660 | "table"
2661 | "tablist"
2662 | "tabpanel"
2663 | "term"
2664 | "textbox"
2665 | "timer"
2666 | "toolbar"
2667 | "tooltip"
2668 | "tree"
2669 | "treegrid"
2670 | "treeitem"
2671 | (string & {});
2672
2673 interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
2674 // React-specific Attributes
2675 defaultChecked?: boolean | undefined;
2676 defaultValue?: string | number | readonly string[] | undefined;
2677 suppressContentEditableWarning?: boolean | undefined;
2678 suppressHydrationWarning?: boolean | undefined;
2679
2680 // Standard HTML Attributes
2681 accessKey?: string | undefined;
2682 autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
2683 autoFocus?: boolean | undefined;
2684 className?: string | undefined;
2685 contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
2686 contextMenu?: string | undefined;
2687 dir?: string | undefined;
2688 draggable?: Booleanish | undefined;
2689 enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
2690 hidden?: boolean | undefined;
2691 id?: string | undefined;
2692 lang?: string | undefined;
2693 nonce?: string | undefined;
2694 slot?: string | undefined;
2695 spellCheck?: Booleanish | undefined;
2696 style?: CSSProperties | undefined;
2697 tabIndex?: number | undefined;
2698 title?: string | undefined;
2699 translate?: "yes" | "no" | undefined;
2700
2701 // Unknown
2702 radioGroup?: string | undefined; // <command>, <menuitem>
2703
2704 // WAI-ARIA
2705 role?: AriaRole | undefined;
2706
2707 // RDFa Attributes
2708 about?: string | undefined;
2709 content?: string | undefined;
2710 datatype?: string | undefined;
2711 inlist?: any;
2712 prefix?: string | undefined;
2713 property?: string | undefined;
2714 rel?: string | undefined;
2715 resource?: string | undefined;
2716 rev?: string | undefined;
2717 typeof?: string | undefined;
2718 vocab?: string | undefined;
2719
2720 // Non-standard Attributes
2721 autoCorrect?: string | undefined;
2722 autoSave?: string | undefined;
2723 color?: string | undefined;
2724 itemProp?: string | undefined;
2725 itemScope?: boolean | undefined;
2726 itemType?: string | undefined;
2727 itemID?: string | undefined;
2728 itemRef?: string | undefined;
2729 results?: number | undefined;
2730 security?: string | undefined;
2731 unselectable?: "on" | "off" | undefined;
2732
2733 // Popover API
2734 popover?: "" | "auto" | "manual" | undefined;
2735 popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
2736 popoverTarget?: string | undefined;
2737
2738 // Living Standard
2739 /**
2740 * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
2741 */
2742 inert?: boolean | undefined;
2743 /**
2744 * Hints at the type of data that might be entered by the user while editing the element or its contents
2745 * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
2746 */
2747 inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
2748 /**
2749 * Specify that a standard HTML element should behave like a defined custom built-in element
2750 * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
2751 */
2752 is?: string | undefined;
2753 }
2754
2755 /**
2756 * For internal usage only.
2757 * Different release channels declare additional types of ReactNode this particular release channel accepts.
2758 * App or library types should never augment this interface.
2759 */
2760 interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {}
2761
2762 interface AllHTMLAttributes<T> extends HTMLAttributes<T> {
2763 // Standard HTML Attributes
2764 accept?: string | undefined;
2765 acceptCharset?: string | undefined;
2766 action?:
2767 | string
2768 | undefined
2769 | ((formData: FormData) => void | Promise<void>)
2770 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2771 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2772 ];
2773 allowFullScreen?: boolean | undefined;
2774 allowTransparency?: boolean | undefined;
2775 alt?: string | undefined;
2776 as?: string | undefined;
2777 async?: boolean | undefined;
2778 autoComplete?: string | undefined;
2779 autoPlay?: boolean | undefined;
2780 capture?: boolean | "user" | "environment" | undefined;
2781 cellPadding?: number | string | undefined;
2782 cellSpacing?: number | string | undefined;
2783 charSet?: string | undefined;
2784 challenge?: string | undefined;
2785 checked?: boolean | undefined;
2786 cite?: string | undefined;
2787 classID?: string | undefined;
2788 cols?: number | undefined;
2789 colSpan?: number | undefined;
2790 controls?: boolean | undefined;
2791 coords?: string | undefined;
2792 crossOrigin?: CrossOrigin;
2793 data?: string | undefined;
2794 dateTime?: string | undefined;
2795 default?: boolean | undefined;
2796 defer?: boolean | undefined;
2797 disabled?: boolean | undefined;
2798 download?: any;
2799 encType?: string | undefined;
2800 form?: string | undefined;
2801 formAction?:
2802 | string
2803 | undefined
2804 | ((formData: FormData) => void | Promise<void>)
2805 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2806 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2807 ];
2808 formEncType?: string | undefined;
2809 formMethod?: string | undefined;
2810 formNoValidate?: boolean | undefined;
2811 formTarget?: string | undefined;
2812 frameBorder?: number | string | undefined;
2813 headers?: string | undefined;
2814 height?: number | string | undefined;
2815 high?: number | undefined;
2816 href?: string | undefined;
2817 hrefLang?: string | undefined;
2818 htmlFor?: string | undefined;
2819 httpEquiv?: string | undefined;
2820 integrity?: string | undefined;
2821 keyParams?: string | undefined;
2822 keyType?: string | undefined;
2823 kind?: string | undefined;
2824 label?: string | undefined;
2825 list?: string | undefined;
2826 loop?: boolean | undefined;
2827 low?: number | undefined;
2828 manifest?: string | undefined;
2829 marginHeight?: number | undefined;
2830 marginWidth?: number | undefined;
2831 max?: number | string | undefined;
2832 maxLength?: number | undefined;
2833 media?: string | undefined;
2834 mediaGroup?: string | undefined;
2835 method?: string | undefined;
2836 min?: number | string | undefined;
2837 minLength?: number | undefined;
2838 multiple?: boolean | undefined;
2839 muted?: boolean | undefined;
2840 name?: string | undefined;
2841 noValidate?: boolean | undefined;
2842 open?: boolean | undefined;
2843 optimum?: number | undefined;
2844 pattern?: string | undefined;
2845 placeholder?: string | undefined;
2846 playsInline?: boolean | undefined;
2847 poster?: string | undefined;
2848 preload?: string | undefined;
2849 readOnly?: boolean | undefined;
2850 required?: boolean | undefined;
2851 reversed?: boolean | undefined;
2852 rows?: number | undefined;
2853 rowSpan?: number | undefined;
2854 sandbox?: string | undefined;
2855 scope?: string | undefined;
2856 scoped?: boolean | undefined;
2857 scrolling?: string | undefined;
2858 seamless?: boolean | undefined;
2859 selected?: boolean | undefined;
2860 shape?: string | undefined;
2861 size?: number | undefined;
2862 sizes?: string | undefined;
2863 span?: number | undefined;
2864 src?: string | undefined;
2865 srcDoc?: string | undefined;
2866 srcLang?: string | undefined;
2867 srcSet?: string | undefined;
2868 start?: number | undefined;
2869 step?: number | string | undefined;
2870 summary?: string | undefined;
2871 target?: string | undefined;
2872 type?: string | undefined;
2873 useMap?: string | undefined;
2874 value?: string | readonly string[] | number | undefined;
2875 width?: number | string | undefined;
2876 wmode?: string | undefined;
2877 wrap?: string | undefined;
2878 }
2879
2880 type HTMLAttributeReferrerPolicy =
2881 | ""
2882 | "no-referrer"
2883 | "no-referrer-when-downgrade"
2884 | "origin"
2885 | "origin-when-cross-origin"
2886 | "same-origin"
2887 | "strict-origin"
2888 | "strict-origin-when-cross-origin"
2889 | "unsafe-url";
2890
2891 type HTMLAttributeAnchorTarget =
2892 | "_self"
2893 | "_blank"
2894 | "_parent"
2895 | "_top"
2896 | (string & {});
2897
2898 interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
2899 download?: any;
2900 href?: string | undefined;
2901 hrefLang?: string | undefined;
2902 media?: string | undefined;
2903 ping?: string | undefined;
2904 target?: HTMLAttributeAnchorTarget | undefined;
2905 type?: string | undefined;
2906 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2907 }
2908
2909 interface AudioHTMLAttributes<T> extends MediaHTMLAttributes<T> {}
2910
2911 interface AreaHTMLAttributes<T> extends HTMLAttributes<T> {
2912 alt?: string | undefined;
2913 coords?: string | undefined;
2914 download?: any;
2915 href?: string | undefined;
2916 hrefLang?: string | undefined;
2917 media?: string | undefined;
2918 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2919 shape?: string | undefined;
2920 target?: string | undefined;
2921 }
2922
2923 interface BaseHTMLAttributes<T> extends HTMLAttributes<T> {
2924 href?: string | undefined;
2925 target?: string | undefined;
2926 }
2927
2928 interface BlockquoteHTMLAttributes<T> extends HTMLAttributes<T> {
2929 cite?: string | undefined;
2930 }
2931
2932 interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
2933 disabled?: boolean | undefined;
2934 form?: string | undefined;
2935 formAction?:
2936 | string
2937 | ((formData: FormData) => void | Promise<void>)
2938 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2939 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2940 ]
2941 | undefined;
2942 formEncType?: string | undefined;
2943 formMethod?: string | undefined;
2944 formNoValidate?: boolean | undefined;
2945 formTarget?: string | undefined;
2946 name?: string | undefined;
2947 type?: "submit" | "reset" | "button" | undefined;
2948 value?: string | readonly string[] | number | undefined;
2949 }
2950
2951 interface CanvasHTMLAttributes<T> extends HTMLAttributes<T> {
2952 height?: number | string | undefined;
2953 width?: number | string | undefined;
2954 }
2955
2956 interface ColHTMLAttributes<T> extends HTMLAttributes<T> {
2957 span?: number | undefined;
2958 width?: number | string | undefined;
2959 }
2960
2961 interface ColgroupHTMLAttributes<T> extends HTMLAttributes<T> {
2962 span?: number | undefined;
2963 }
2964
2965 interface DataHTMLAttributes<T> extends HTMLAttributes<T> {
2966 value?: string | readonly string[] | number | undefined;
2967 }
2968
2969 interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
2970 open?: boolean | undefined;
2971 name?: string | undefined;
2972 }
2973
2974 interface DelHTMLAttributes<T> extends HTMLAttributes<T> {
2975 cite?: string | undefined;
2976 dateTime?: string | undefined;
2977 }
2978
2979 interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
2980 onCancel?: ReactEventHandler<T> | undefined;
2981 onClose?: ReactEventHandler<T> | undefined;
2982 open?: boolean | undefined;
2983 }
2984
2985 interface EmbedHTMLAttributes<T> extends HTMLAttributes<T> {
2986 height?: number | string | undefined;
2987 src?: string | undefined;
2988 type?: string | undefined;
2989 width?: number | string | undefined;
2990 }
2991
2992 interface FieldsetHTMLAttributes<T> extends HTMLAttributes<T> {
2993 disabled?: boolean | undefined;
2994 form?: string | undefined;
2995 name?: string | undefined;
2996 }
2997
2998 interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
2999 acceptCharset?: string | undefined;
3000 action?:
3001 | string
3002 | undefined
3003 | ((formData: FormData) => void | Promise<void>)
3004 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3005 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3006 ];
3007 autoComplete?: string | undefined;
3008 encType?: string | undefined;
3009 method?: string | undefined;
3010 name?: string | undefined;
3011 noValidate?: boolean | undefined;
3012 target?: string | undefined;
3013 }
3014
3015 interface HtmlHTMLAttributes<T> extends HTMLAttributes<T> {
3016 manifest?: string | undefined;
3017 }
3018
3019 interface IframeHTMLAttributes<T> extends HTMLAttributes<T> {
3020 allow?: string | undefined;
3021 allowFullScreen?: boolean | undefined;
3022 allowTransparency?: boolean | undefined;
3023 /** @deprecated */
3024 frameBorder?: number | string | undefined;
3025 height?: number | string | undefined;
3026 loading?: "eager" | "lazy" | undefined;
3027 /** @deprecated */
3028 marginHeight?: number | undefined;
3029 /** @deprecated */
3030 marginWidth?: number | undefined;
3031 name?: string | undefined;
3032 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3033 sandbox?: string | undefined;
3034 /** @deprecated */
3035 scrolling?: string | undefined;
3036 seamless?: boolean | undefined;
3037 src?: string | undefined;
3038 srcDoc?: string | undefined;
3039 width?: number | string | undefined;
3040 }
3041
3042 interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
3043 alt?: string | undefined;
3044 crossOrigin?: CrossOrigin;
3045 decoding?: "async" | "auto" | "sync" | undefined;
3046 fetchPriority?: "high" | "low" | "auto";
3047 height?: number | string | undefined;
3048 loading?: "eager" | "lazy" | undefined;
3049 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3050 sizes?: string | undefined;
3051 src?: string | undefined;
3052 srcSet?: string | undefined;
3053 useMap?: string | undefined;
3054 width?: number | string | undefined;
3055 }
3056
3057 interface InsHTMLAttributes<T> extends HTMLAttributes<T> {
3058 cite?: string | undefined;
3059 dateTime?: string | undefined;
3060 }
3061
3062 type HTMLInputTypeAttribute =
3063 | "button"
3064 | "checkbox"
3065 | "color"
3066 | "date"
3067 | "datetime-local"
3068 | "email"
3069 | "file"
3070 | "hidden"
3071 | "image"
3072 | "month"
3073 | "number"
3074 | "password"
3075 | "radio"
3076 | "range"
3077 | "reset"
3078 | "search"
3079 | "submit"
3080 | "tel"
3081 | "text"
3082 | "time"
3083 | "url"
3084 | "week"
3085 | (string & {});
3086
3087 type AutoFillAddressKind = "billing" | "shipping";
3088 type AutoFillBase = "" | "off" | "on";
3089 type AutoFillContactField =
3090 | "email"
3091 | "tel"
3092 | "tel-area-code"
3093 | "tel-country-code"
3094 | "tel-extension"
3095 | "tel-local"
3096 | "tel-local-prefix"
3097 | "tel-local-suffix"
3098 | "tel-national";
3099 type AutoFillContactKind = "home" | "mobile" | "work";
3100 type AutoFillCredentialField = "webauthn";
3101 type AutoFillNormalField =
3102 | "additional-name"
3103 | "address-level1"
3104 | "address-level2"
3105 | "address-level3"
3106 | "address-level4"
3107 | "address-line1"
3108 | "address-line2"
3109 | "address-line3"
3110 | "bday-day"
3111 | "bday-month"
3112 | "bday-year"
3113 | "cc-csc"
3114 | "cc-exp"
3115 | "cc-exp-month"
3116 | "cc-exp-year"
3117 | "cc-family-name"
3118 | "cc-given-name"
3119 | "cc-name"
3120 | "cc-number"
3121 | "cc-type"
3122 | "country"
3123 | "country-name"
3124 | "current-password"
3125 | "family-name"
3126 | "given-name"
3127 | "honorific-prefix"
3128 | "honorific-suffix"
3129 | "name"
3130 | "new-password"
3131 | "one-time-code"
3132 | "organization"
3133 | "postal-code"
3134 | "street-address"
3135 | "transaction-amount"
3136 | "transaction-currency"
3137 | "username";
3138 type OptionalPrefixToken<T extends string> = `${T} ` | "";
3139 type OptionalPostfixToken<T extends string> = ` ${T}` | "";
3140 type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`;
3141 type AutoFillSection = `section-${string}`;
3142 type AutoFill =
3143 | AutoFillBase
3144 | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<
3145 AutoFillAddressKind
3146 >}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`;
3147 type HTMLInputAutoCompleteAttribute = AutoFill | (string & {});
3148
3149 interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
3150 accept?: string | undefined;
3151 alt?: string | undefined;
3152 autoComplete?: HTMLInputAutoCompleteAttribute | undefined;
3153 capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3154 checked?: boolean | undefined;
3155 disabled?: boolean | undefined;
3156 form?: string | undefined;
3157 formAction?:
3158 | string
3159 | ((formData: FormData) => void | Promise<void>)
3160 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3161 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3162 ]
3163 | undefined;
3164 formEncType?: string | undefined;
3165 formMethod?: string | undefined;
3166 formNoValidate?: boolean | undefined;
3167 formTarget?: string | undefined;
3168 height?: number | string | undefined;
3169 list?: string | undefined;
3170 max?: number | string | undefined;
3171 maxLength?: number | undefined;
3172 min?: number | string | undefined;
3173 minLength?: number | undefined;
3174 multiple?: boolean | undefined;
3175 name?: string | undefined;
3176 pattern?: string | undefined;
3177 placeholder?: string | undefined;
3178 readOnly?: boolean | undefined;
3179 required?: boolean | undefined;
3180 size?: number | undefined;
3181 src?: string | undefined;
3182 step?: number | string | undefined;
3183 type?: HTMLInputTypeAttribute | undefined;
3184 value?: string | readonly string[] | number | undefined;
3185 width?: number | string | undefined;
3186
3187 onChange?: ChangeEventHandler<T> | undefined;
3188 }
3189
3190 interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
3191 challenge?: string | undefined;
3192 disabled?: boolean | undefined;
3193 form?: string | undefined;
3194 keyType?: string | undefined;
3195 keyParams?: string | undefined;
3196 name?: string | undefined;
3197 }
3198
3199 interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
3200 form?: string | undefined;
3201 htmlFor?: string | undefined;
3202 }
3203
3204 interface LiHTMLAttributes<T> extends HTMLAttributes<T> {
3205 value?: string | readonly string[] | number | undefined;
3206 }
3207
3208 interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
3209 as?: string | undefined;
3210 crossOrigin?: CrossOrigin;
3211 fetchPriority?: "high" | "low" | "auto";
3212 href?: string | undefined;
3213 hrefLang?: string | undefined;
3214 integrity?: string | undefined;
3215 media?: string | undefined;
3216 imageSrcSet?: string | undefined;
3217 imageSizes?: string | undefined;
3218 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3219 sizes?: string | undefined;
3220 type?: string | undefined;
3221 charSet?: string | undefined;
3222
3223 // React props
3224 precedence?: string | undefined;
3225 }
3226
3227 interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
3228 name?: string | undefined;
3229 }
3230
3231 interface MenuHTMLAttributes<T> extends HTMLAttributes<T> {
3232 type?: string | undefined;
3233 }
3234
3235 interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
3236 autoPlay?: boolean | undefined;
3237 controls?: boolean | undefined;
3238 controlsList?: string | undefined;
3239 crossOrigin?: CrossOrigin;
3240 loop?: boolean | undefined;
3241 mediaGroup?: string | undefined;
3242 muted?: boolean | undefined;
3243 playsInline?: boolean | undefined;
3244 preload?: string | undefined;
3245 src?: string | undefined;
3246 }
3247
3248 interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
3249 charSet?: string | undefined;
3250 content?: string | undefined;
3251 httpEquiv?: string | undefined;
3252 media?: string | undefined;
3253 name?: string | undefined;
3254 }
3255
3256 interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
3257 form?: string | undefined;
3258 high?: number | undefined;
3259 low?: number | undefined;
3260 max?: number | string | undefined;
3261 min?: number | string | undefined;
3262 optimum?: number | undefined;
3263 value?: string | readonly string[] | number | undefined;
3264 }
3265
3266 interface QuoteHTMLAttributes<T> extends HTMLAttributes<T> {
3267 cite?: string | undefined;
3268 }
3269
3270 interface ObjectHTMLAttributes<T> extends HTMLAttributes<T> {
3271 classID?: string | undefined;
3272 data?: string | undefined;
3273 form?: string | undefined;
3274 height?: number | string | undefined;
3275 name?: string | undefined;
3276 type?: string | undefined;
3277 useMap?: string | undefined;
3278 width?: number | string | undefined;
3279 wmode?: string | undefined;
3280 }
3281
3282 interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
3283 reversed?: boolean | undefined;
3284 start?: number | undefined;
3285 type?: "1" | "a" | "A" | "i" | "I" | undefined;
3286 }
3287
3288 interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
3289 disabled?: boolean | undefined;
3290 label?: string | undefined;
3291 }
3292
3293 interface OptionHTMLAttributes<T> extends HTMLAttributes<T> {
3294 disabled?: boolean | undefined;
3295 label?: string | undefined;
3296 selected?: boolean | undefined;
3297 value?: string | readonly string[] | number | undefined;
3298 }
3299
3300 interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
3301 form?: string | undefined;
3302 htmlFor?: string | undefined;
3303 name?: string | undefined;
3304 }
3305
3306 interface ParamHTMLAttributes<T> extends HTMLAttributes<T> {
3307 name?: string | undefined;
3308 value?: string | readonly string[] | number | undefined;
3309 }
3310
3311 interface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {
3312 max?: number | string | undefined;
3313 value?: string | readonly string[] | number | undefined;
3314 }
3315
3316 interface SlotHTMLAttributes<T> extends HTMLAttributes<T> {
3317 name?: string | undefined;
3318 }
3319
3320 interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
3321 async?: boolean | undefined;
3322 /** @deprecated */
3323 charSet?: string | undefined;
3324 crossOrigin?: CrossOrigin;
3325 defer?: boolean | undefined;
3326 integrity?: string | undefined;
3327 noModule?: boolean | undefined;
3328 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3329 src?: string | undefined;
3330 type?: string | undefined;
3331 }
3332
3333 interface SelectHTMLAttributes<T> extends HTMLAttributes<T> {
3334 autoComplete?: string | undefined;
3335 disabled?: boolean | undefined;
3336 form?: string | undefined;
3337 multiple?: boolean | undefined;
3338 name?: string | undefined;
3339 required?: boolean | undefined;
3340 size?: number | undefined;
3341 value?: string | readonly string[] | number | undefined;
3342 onChange?: ChangeEventHandler<T> | undefined;
3343 }
3344
3345 interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
3346 height?: number | string | undefined;
3347 media?: string | undefined;
3348 sizes?: string | undefined;
3349 src?: string | undefined;
3350 srcSet?: string | undefined;
3351 type?: string | undefined;
3352 width?: number | string | undefined;
3353 }
3354
3355 interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
3356 media?: string | undefined;
3357 scoped?: boolean | undefined;
3358 type?: string | undefined;
3359
3360 // React props
3361 href?: string | undefined;
3362 precedence?: string | undefined;
3363 }
3364
3365 interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
3366 align?: "left" | "center" | "right" | undefined;
3367 bgcolor?: string | undefined;
3368 border?: number | undefined;
3369 cellPadding?: number | string | undefined;
3370 cellSpacing?: number | string | undefined;
3371 frame?: boolean | undefined;
3372 rules?: "none" | "groups" | "rows" | "columns" | "all" | undefined;
3373 summary?: string | undefined;
3374 width?: number | string | undefined;
3375 }
3376
3377 interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
3378 autoComplete?: string | undefined;
3379 cols?: number | undefined;
3380 dirName?: string | undefined;
3381 disabled?: boolean | undefined;
3382 form?: string | undefined;
3383 maxLength?: number | undefined;
3384 minLength?: number | undefined;
3385 name?: string | undefined;
3386 placeholder?: string | undefined;
3387 readOnly?: boolean | undefined;
3388 required?: boolean | undefined;
3389 rows?: number | undefined;
3390 value?: string | readonly string[] | number | undefined;
3391 wrap?: string | undefined;
3392
3393 onChange?: ChangeEventHandler<T> | undefined;
3394 }
3395
3396 interface TdHTMLAttributes<T> extends HTMLAttributes<T> {
3397 align?: "left" | "center" | "right" | "justify" | "char" | undefined;
3398 colSpan?: number | undefined;
3399 headers?: string | undefined;
3400 rowSpan?: number | undefined;
3401 scope?: string | undefined;
3402 abbr?: string | undefined;
3403 height?: number | string | undefined;
3404 width?: number | string | undefined;
3405 valign?: "top" | "middle" | "bottom" | "baseline" | undefined;
3406 }
3407
3408 interface ThHTMLAttributes<T> extends HTMLAttributes<T> {
3409 align?: "left" | "center" | "right" | "justify" | "char" | undefined;
3410 colSpan?: number | undefined;
3411 headers?: string | undefined;
3412 rowSpan?: number | undefined;
3413 scope?: string | undefined;
3414 abbr?: string | undefined;
3415 }
3416
3417 interface TimeHTMLAttributes<T> extends HTMLAttributes<T> {
3418 dateTime?: string | undefined;
3419 }
3420
3421 interface TrackHTMLAttributes<T> extends HTMLAttributes<T> {
3422 default?: boolean | undefined;
3423 kind?: string | undefined;
3424 label?: string | undefined;
3425 src?: string | undefined;
3426 srcLang?: string | undefined;
3427 }
3428
3429 interface VideoHTMLAttributes<T> extends MediaHTMLAttributes<T> {
3430 height?: number | string | undefined;
3431 playsInline?: boolean | undefined;
3432 poster?: string | undefined;
3433 width?: number | string | undefined;
3434 disablePictureInPicture?: boolean | undefined;
3435 disableRemotePlayback?: boolean | undefined;
3436 }
3437
3438 // this list is "complete" in that it contains every SVG attribute
3439 // that React supports, but the types can be improved.
3440 // Full list here: https://facebook.github.io/react/docs/dom-elements.html
3441 //
3442 // The three broad type categories are (in order of restrictiveness):
3443 // - "number | string"
3444 // - "string"
3445 // - union of string literals
3446 interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
3447 // React-specific Attributes
3448 suppressHydrationWarning?: boolean | undefined;
3449
3450 // Attributes which also defined in HTMLAttributes
3451 // See comment in SVGDOMPropertyConfig.js
3452 className?: string | undefined;
3453 color?: string | undefined;
3454 height?: number | string | undefined;
3455 id?: string | undefined;
3456 lang?: string | undefined;
3457 max?: number | string | undefined;
3458 media?: string | undefined;
3459 method?: string | undefined;
3460 min?: number | string | undefined;
3461 name?: string | undefined;
3462 style?: CSSProperties | undefined;
3463 target?: string | undefined;
3464 type?: string | undefined;
3465 width?: number | string | undefined;
3466
3467 // Other HTML properties supported by SVG elements in browsers
3468 role?: AriaRole | undefined;
3469 tabIndex?: number | undefined;
3470 crossOrigin?: CrossOrigin;
3471
3472 // SVG Specific attributes
3473 accentHeight?: number | string | undefined;
3474 accumulate?: "none" | "sum" | undefined;
3475 additive?: "replace" | "sum" | undefined;
3476 alignmentBaseline?:
3477 | "auto"
3478 | "baseline"
3479 | "before-edge"
3480 | "text-before-edge"
3481 | "middle"
3482 | "central"
3483 | "after-edge"
3484 | "text-after-edge"
3485 | "ideographic"
3486 | "alphabetic"
3487 | "hanging"
3488 | "mathematical"
3489 | "inherit"
3490 | undefined;
3491 allowReorder?: "no" | "yes" | undefined;
3492 alphabetic?: number | string | undefined;
3493 amplitude?: number | string | undefined;
3494 arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
3495 ascent?: number | string | undefined;
3496 attributeName?: string | undefined;
3497 attributeType?: string | undefined;
3498 autoReverse?: Booleanish | undefined;
3499 azimuth?: number | string | undefined;
3500 baseFrequency?: number | string | undefined;
3501 baselineShift?: number | string | undefined;
3502 baseProfile?: number | string | undefined;
3503 bbox?: number | string | undefined;
3504 begin?: number | string | undefined;
3505 bias?: number | string | undefined;
3506 by?: number | string | undefined;
3507 calcMode?: number | string | undefined;
3508 capHeight?: number | string | undefined;
3509 clip?: number | string | undefined;
3510 clipPath?: string | undefined;
3511 clipPathUnits?: number | string | undefined;
3512 clipRule?: number | string | undefined;
3513 colorInterpolation?: number | string | undefined;
3514 colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
3515 colorProfile?: number | string | undefined;
3516 colorRendering?: number | string | undefined;
3517 contentScriptType?: number | string | undefined;
3518 contentStyleType?: number | string | undefined;
3519 cursor?: number | string | undefined;
3520 cx?: number | string | undefined;
3521 cy?: number | string | undefined;
3522 d?: string | undefined;
3523 decelerate?: number | string | undefined;
3524 descent?: number | string | undefined;
3525 diffuseConstant?: number | string | undefined;
3526 direction?: number | string | undefined;
3527 display?: number | string | undefined;
3528 divisor?: number | string | undefined;
3529 dominantBaseline?: number | string | undefined;
3530 dur?: number | string | undefined;
3531 dx?: number | string | undefined;
3532 dy?: number | string | undefined;
3533 edgeMode?: number | string | undefined;
3534 elevation?: number | string | undefined;
3535 enableBackground?: number | string | undefined;
3536 end?: number | string | undefined;
3537 exponent?: number | string | undefined;
3538 externalResourcesRequired?: Booleanish | undefined;
3539 fill?: string | undefined;
3540 fillOpacity?: number | string | undefined;
3541 fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
3542 filter?: string | undefined;
3543 filterRes?: number | string | undefined;
3544 filterUnits?: number | string | undefined;
3545 floodColor?: number | string | undefined;
3546 floodOpacity?: number | string | undefined;
3547 focusable?: Booleanish | "auto" | undefined;
3548 fontFamily?: string | undefined;
3549 fontSize?: number | string | undefined;
3550 fontSizeAdjust?: number | string | undefined;
3551 fontStretch?: number | string | undefined;
3552 fontStyle?: number | string | undefined;
3553 fontVariant?: number | string | undefined;
3554 fontWeight?: number | string | undefined;
3555 format?: number | string | undefined;
3556 fr?: number | string | undefined;
3557 from?: number | string | undefined;
3558 fx?: number | string | undefined;
3559 fy?: number | string | undefined;
3560 g1?: number | string | undefined;
3561 g2?: number | string | undefined;
3562 glyphName?: number | string | undefined;
3563 glyphOrientationHorizontal?: number | string | undefined;
3564 glyphOrientationVertical?: number | string | undefined;
3565 glyphRef?: number | string | undefined;
3566 gradientTransform?: string | undefined;
3567 gradientUnits?: string | undefined;
3568 hanging?: number | string | undefined;
3569 horizAdvX?: number | string | undefined;
3570 horizOriginX?: number | string | undefined;
3571 href?: string | undefined;
3572 ideographic?: number | string | undefined;
3573 imageRendering?: number | string | undefined;
3574 in2?: number | string | undefined;
3575 in?: string | undefined;
3576 intercept?: number | string | undefined;
3577 k1?: number | string | undefined;
3578 k2?: number | string | undefined;
3579 k3?: number | string | undefined;
3580 k4?: number | string | undefined;
3581 k?: number | string | undefined;
3582 kernelMatrix?: number | string | undefined;
3583 kernelUnitLength?: number | string | undefined;
3584 kerning?: number | string | undefined;
3585 keyPoints?: number | string | undefined;
3586 keySplines?: number | string | undefined;
3587 keyTimes?: number | string | undefined;
3588 lengthAdjust?: number | string | undefined;
3589 letterSpacing?: number | string | undefined;
3590 lightingColor?: number | string | undefined;
3591 limitingConeAngle?: number | string | undefined;
3592 local?: number | string | undefined;
3593 markerEnd?: string | undefined;
3594 markerHeight?: number | string | undefined;
3595 markerMid?: string | undefined;
3596 markerStart?: string | undefined;
3597 markerUnits?: number | string | undefined;
3598 markerWidth?: number | string | undefined;
3599 mask?: string | undefined;
3600 maskContentUnits?: number | string | undefined;
3601 maskUnits?: number | string | undefined;
3602 mathematical?: number | string | undefined;
3603 mode?: number | string | undefined;
3604 numOctaves?: number | string | undefined;
3605 offset?: number | string | undefined;
3606 opacity?: number | string | undefined;
3607 operator?: number | string | undefined;
3608 order?: number | string | undefined;
3609 orient?: number | string | undefined;
3610 orientation?: number | string | undefined;
3611 origin?: number | string | undefined;
3612 overflow?: number | string | undefined;
3613 overlinePosition?: number | string | undefined;
3614 overlineThickness?: number | string | undefined;
3615 paintOrder?: number | string | undefined;
3616 panose1?: number | string | undefined;
3617 path?: string | undefined;
3618 pathLength?: number | string | undefined;
3619 patternContentUnits?: string | undefined;
3620 patternTransform?: number | string | undefined;
3621 patternUnits?: string | undefined;
3622 pointerEvents?: number | string | undefined;
3623 points?: string | undefined;
3624 pointsAtX?: number | string | undefined;
3625 pointsAtY?: number | string | undefined;
3626 pointsAtZ?: number | string | undefined;
3627 preserveAlpha?: Booleanish | undefined;
3628 preserveAspectRatio?: string | undefined;
3629 primitiveUnits?: number | string | undefined;
3630 r?: number | string | undefined;
3631 radius?: number | string | undefined;
3632 refX?: number | string | undefined;
3633 refY?: number | string | undefined;
3634 renderingIntent?: number | string | undefined;
3635 repeatCount?: number | string | undefined;
3636 repeatDur?: number | string | undefined;
3637 requiredExtensions?: number | string | undefined;
3638 requiredFeatures?: number | string | undefined;
3639 restart?: number | string | undefined;
3640 result?: string | undefined;
3641 rotate?: number | string | undefined;
3642 rx?: number | string | undefined;
3643 ry?: number | string | undefined;
3644 scale?: number | string | undefined;
3645 seed?: number | string | undefined;
3646 shapeRendering?: number | string | undefined;
3647 slope?: number | string | undefined;
3648 spacing?: number | string | undefined;
3649 specularConstant?: number | string | undefined;
3650 specularExponent?: number | string | undefined;
3651 speed?: number | string | undefined;
3652 spreadMethod?: string | undefined;
3653 startOffset?: number | string | undefined;
3654 stdDeviation?: number | string | undefined;
3655 stemh?: number | string | undefined;
3656 stemv?: number | string | undefined;
3657 stitchTiles?: number | string | undefined;
3658 stopColor?: string | undefined;
3659 stopOpacity?: number | string | undefined;
3660 strikethroughPosition?: number | string | undefined;
3661 strikethroughThickness?: number | string | undefined;
3662 string?: number | string | undefined;
3663 stroke?: string | undefined;
3664 strokeDasharray?: string | number | undefined;
3665 strokeDashoffset?: string | number | undefined;
3666 strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
3667 strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
3668 strokeMiterlimit?: number | string | undefined;
3669 strokeOpacity?: number | string | undefined;
3670 strokeWidth?: number | string | undefined;
3671 surfaceScale?: number | string | undefined;
3672 systemLanguage?: number | string | undefined;
3673 tableValues?: number | string | undefined;
3674 targetX?: number | string | undefined;
3675 targetY?: number | string | undefined;
3676 textAnchor?: string | undefined;
3677 textDecoration?: number | string | undefined;
3678 textLength?: number | string | undefined;
3679 textRendering?: number | string | undefined;
3680 to?: number | string | undefined;
3681 transform?: string | undefined;
3682 u1?: number | string | undefined;
3683 u2?: number | string | undefined;
3684 underlinePosition?: number | string | undefined;
3685 underlineThickness?: number | string | undefined;
3686 unicode?: number | string | undefined;
3687 unicodeBidi?: number | string | undefined;
3688 unicodeRange?: number | string | undefined;
3689 unitsPerEm?: number | string | undefined;
3690 vAlphabetic?: number | string | undefined;
3691 values?: string | undefined;
3692 vectorEffect?: number | string | undefined;
3693 version?: string | undefined;
3694 vertAdvY?: number | string | undefined;
3695 vertOriginX?: number | string | undefined;
3696 vertOriginY?: number | string | undefined;
3697 vHanging?: number | string | undefined;
3698 vIdeographic?: number | string | undefined;
3699 viewBox?: string | undefined;
3700 viewTarget?: number | string | undefined;
3701 visibility?: number | string | undefined;
3702 vMathematical?: number | string | undefined;
3703 widths?: number | string | undefined;
3704 wordSpacing?: number | string | undefined;
3705 writingMode?: number | string | undefined;
3706 x1?: number | string | undefined;
3707 x2?: number | string | undefined;
3708 x?: number | string | undefined;
3709 xChannelSelector?: string | undefined;
3710 xHeight?: number | string | undefined;
3711 xlinkActuate?: string | undefined;
3712 xlinkArcrole?: string | undefined;
3713 xlinkHref?: string | undefined;
3714 xlinkRole?: string | undefined;
3715 xlinkShow?: string | undefined;
3716 xlinkTitle?: string | undefined;
3717 xlinkType?: string | undefined;
3718 xmlBase?: string | undefined;
3719 xmlLang?: string | undefined;
3720 xmlns?: string | undefined;
3721 xmlnsXlink?: string | undefined;
3722 xmlSpace?: string | undefined;
3723 y1?: number | string | undefined;
3724 y2?: number | string | undefined;
3725 y?: number | string | undefined;
3726 yChannelSelector?: string | undefined;
3727 z?: number | string | undefined;
3728 zoomAndPan?: string | undefined;
3729 }
3730
3731 interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
3732 allowFullScreen?: boolean | undefined;
3733 allowpopups?: boolean | undefined;
3734 autosize?: boolean | undefined;
3735 blinkfeatures?: string | undefined;
3736 disableblinkfeatures?: string | undefined;
3737 disableguestresize?: boolean | undefined;
3738 disablewebsecurity?: boolean | undefined;
3739 guestinstance?: string | undefined;
3740 httpreferrer?: string | undefined;
3741 nodeintegration?: boolean | undefined;
3742 partition?: string | undefined;
3743 plugins?: boolean | undefined;
3744 preload?: string | undefined;
3745 src?: string | undefined;
3746 useragent?: string | undefined;
3747 webpreferences?: string | undefined;
3748 }
3749
3750 // TODO: Move to react-dom
3751 type HTMLElementType =
3752 | "a"
3753 | "abbr"
3754 | "address"
3755 | "area"
3756 | "article"
3757 | "aside"
3758 | "audio"
3759 | "b"
3760 | "base"
3761 | "bdi"
3762 | "bdo"
3763 | "big"
3764 | "blockquote"
3765 | "body"
3766 | "br"
3767 | "button"
3768 | "canvas"
3769 | "caption"
3770 | "center"
3771 | "cite"
3772 | "code"
3773 | "col"
3774 | "colgroup"
3775 | "data"
3776 | "datalist"
3777 | "dd"
3778 | "del"
3779 | "details"
3780 | "dfn"
3781 | "dialog"
3782 | "div"
3783 | "dl"
3784 | "dt"
3785 | "em"
3786 | "embed"
3787 | "fieldset"
3788 | "figcaption"
3789 | "figure"
3790 | "footer"
3791 | "form"
3792 | "h1"
3793 | "h2"
3794 | "h3"
3795 | "h4"
3796 | "h5"
3797 | "h6"
3798 | "head"
3799 | "header"
3800 | "hgroup"
3801 | "hr"
3802 | "html"
3803 | "i"
3804 | "iframe"
3805 | "img"
3806 | "input"
3807 | "ins"
3808 | "kbd"
3809 | "keygen"
3810 | "label"
3811 | "legend"
3812 | "li"
3813 | "link"
3814 | "main"
3815 | "map"
3816 | "mark"
3817 | "menu"
3818 | "menuitem"
3819 | "meta"
3820 | "meter"
3821 | "nav"
3822 | "noscript"
3823 | "object"
3824 | "ol"
3825 | "optgroup"
3826 | "option"
3827 | "output"
3828 | "p"
3829 | "param"
3830 | "picture"
3831 | "pre"
3832 | "progress"
3833 | "q"
3834 | "rp"
3835 | "rt"
3836 | "ruby"
3837 | "s"
3838 | "samp"
3839 | "search"
3840 | "slot"
3841 | "script"
3842 | "section"
3843 | "select"
3844 | "small"
3845 | "source"
3846 | "span"
3847 | "strong"
3848 | "style"
3849 | "sub"
3850 | "summary"
3851 | "sup"
3852 | "table"
3853 | "template"
3854 | "tbody"
3855 | "td"
3856 | "textarea"
3857 | "tfoot"
3858 | "th"
3859 | "thead"
3860 | "time"
3861 | "title"
3862 | "tr"
3863 | "track"
3864 | "u"
3865 | "ul"
3866 | "var"
3867 | "video"
3868 | "wbr"
3869 | "webview";
3870
3871 // TODO: Move to react-dom
3872 type SVGElementType =
3873 | "animate"
3874 | "circle"
3875 | "clipPath"
3876 | "defs"
3877 | "desc"
3878 | "ellipse"
3879 | "feBlend"
3880 | "feColorMatrix"
3881 | "feComponentTransfer"
3882 | "feComposite"
3883 | "feConvolveMatrix"
3884 | "feDiffuseLighting"
3885 | "feDisplacementMap"
3886 | "feDistantLight"
3887 | "feDropShadow"
3888 | "feFlood"
3889 | "feFuncA"
3890 | "feFuncB"
3891 | "feFuncG"
3892 | "feFuncR"
3893 | "feGaussianBlur"
3894 | "feImage"
3895 | "feMerge"
3896 | "feMergeNode"
3897 | "feMorphology"
3898 | "feOffset"
3899 | "fePointLight"
3900 | "feSpecularLighting"
3901 | "feSpotLight"
3902 | "feTile"
3903 | "feTurbulence"
3904 | "filter"
3905 | "foreignObject"
3906 | "g"
3907 | "image"
3908 | "line"
3909 | "linearGradient"
3910 | "marker"
3911 | "mask"
3912 | "metadata"
3913 | "path"
3914 | "pattern"
3915 | "polygon"
3916 | "polyline"
3917 | "radialGradient"
3918 | "rect"
3919 | "stop"
3920 | "svg"
3921 | "switch"
3922 | "symbol"
3923 | "text"
3924 | "textPath"
3925 | "tspan"
3926 | "use"
3927 | "view";
3928
3929 //
3930 // Browser Interfaces
3931 // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
3932 // ----------------------------------------------------------------------
3933
3934 interface AbstractView {
3935 styleMedia: StyleMedia;
3936 document: Document;
3937 }
3938
3939 interface Touch {
3940 identifier: number;
3941 target: EventTarget;
3942 screenX: number;
3943 screenY: number;
3944 clientX: number;
3945 clientY: number;
3946 pageX: number;
3947 pageY: number;
3948 }
3949
3950 interface TouchList {
3951 [index: number]: Touch;
3952 length: number;
3953 item(index: number): Touch;
3954 identifiedTouch(identifier: number): Touch;
3955 }
3956
3957 //
3958 // Error Interfaces
3959 // ----------------------------------------------------------------------
3960 interface ErrorInfo {
3961 /**
3962 * Captures which component contained the exception, and its ancestors.
3963 */
3964 componentStack?: string | null;
3965 digest?: string | null;
3966 }
3967
3968 // Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
3969 namespace JSX {
3970 // We don't just alias React.ElementType because React.ElementType
3971 // historically does more than we need it to.
3972 // E.g. it also contains .propTypes and so TS also verifies the declared
3973 // props type does match the declared .propTypes.
3974 // But if libraries declared their .propTypes but not props type,
3975 // or they mismatch, you won't be able to use the class component
3976 // as a JSX.ElementType.
3977 // We could fix this everywhere but we're ultimately not interested in
3978 // .propTypes assignability so we might as well drop it entirely here to
3979 // reduce the work of the type-checker.
3980 // TODO: Check impact of making React.ElementType<P = any> = React.JSXElementConstructor<P>
3981 type ElementType = string | React.JSXElementConstructor<any>;
3982 interface Element extends React.ReactElement<any, any> {}
3983 interface ElementClass extends React.Component<any> {
3984 render(): React.ReactNode;
3985 }
3986 interface ElementAttributesProperty {
3987 props: {};
3988 }
3989 interface ElementChildrenAttribute {
3990 children: {};
3991 }
3992
3993 // We can't recurse forever because `type` can't be self-referential;
3994 // let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
3995 type LibraryManagedAttributes<C, P> = C extends
3996 React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
3997 ? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
3998 ? ReactManagedAttributes<U, P>
3999 : ReactManagedAttributes<T, P>
4000 : ReactManagedAttributes<C, P>;
4001
4002 interface IntrinsicAttributes extends React.Attributes {}
4003 interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {}
4004
4005 interface IntrinsicElements {
4006 // HTML
4007 a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
4008 abbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4009 address: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4010 area: React.DetailedHTMLProps<React.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
4011 article: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4012 aside: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4013 audio: React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
4014 b: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4015 base: React.DetailedHTMLProps<React.BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
4016 bdi: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4017 bdo: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4018 big: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4019 blockquote: React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4020 body: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
4021 br: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
4022 button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
4023 canvas: React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
4024 caption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4025 center: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4026 cite: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4027 code: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4028 col: React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
4029 colgroup: React.DetailedHTMLProps<React.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
4030 data: React.DetailedHTMLProps<React.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
4031 datalist: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
4032 dd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4033 del: React.DetailedHTMLProps<React.DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
4034 details: React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
4035 dfn: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4036 dialog: React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
4037 div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
4038 dl: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
4039 dt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4040 em: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4041 embed: React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
4042 fieldset: React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
4043 figcaption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4044 figure: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4045 footer: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4046 form: React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
4047 h1: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4048 h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4049 h3: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4050 h4: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4051 h5: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4052 h6: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4053 head: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>;
4054 header: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4055 hgroup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4056 hr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
4057 html: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
4058 i: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4059 iframe: React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
4060 img: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
4061 input: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4062 ins: React.DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
4063 kbd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4064 keygen: React.DetailedHTMLProps<React.KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
4065 label: React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
4066 legend: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
4067 li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
4068 link: React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
4069 main: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4070 map: React.DetailedHTMLProps<React.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
4071 mark: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4072 menu: React.DetailedHTMLProps<React.MenuHTMLAttributes<HTMLElement>, HTMLElement>;
4073 menuitem: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4074 meta: React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
4075 meter: React.DetailedHTMLProps<React.MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
4076 nav: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4077 noindex: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4078 noscript: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4079 object: React.DetailedHTMLProps<React.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
4080 ol: React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
4081 optgroup: React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
4082 option: React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
4083 output: React.DetailedHTMLProps<React.OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
4084 p: React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
4085 param: React.DetailedHTMLProps<React.ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
4086 picture: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4087 pre: React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
4088 progress: React.DetailedHTMLProps<React.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
4089 q: React.DetailedHTMLProps<React.QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4090 rp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4091 rt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4092 ruby: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4093 s: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4094 samp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4095 search: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4096 slot: React.DetailedHTMLProps<React.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
4097 script: React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
4098 section: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4099 select: React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
4100 small: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4101 source: React.DetailedHTMLProps<React.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
4102 span: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
4103 strong: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4104 style: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
4105 sub: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4106 summary: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4107 sup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4108 table: React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
4109 template: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
4110 tbody: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4111 td: React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
4112 textarea: React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
4113 tfoot: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4114 th: React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
4115 thead: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4116 time: React.DetailedHTMLProps<React.TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
4117 title: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
4118 tr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
4119 track: React.DetailedHTMLProps<React.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
4120 u: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4121 ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
4122 "var": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4123 video: React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
4124 wbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4125 webview: React.DetailedHTMLProps<React.WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
4126
4127 // SVG
4128 svg: React.SVGProps<SVGSVGElement>;
4129
4130 animate: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now.
4131 animateMotion: React.SVGProps<SVGElement>;
4132 animateTransform: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now.
4133 circle: React.SVGProps<SVGCircleElement>;
4134 clipPath: React.SVGProps<SVGClipPathElement>;
4135 defs: React.SVGProps<SVGDefsElement>;
4136 desc: React.SVGProps<SVGDescElement>;
4137 ellipse: React.SVGProps<SVGEllipseElement>;
4138 feBlend: React.SVGProps<SVGFEBlendElement>;
4139 feColorMatrix: React.SVGProps<SVGFEColorMatrixElement>;
4140 feComponentTransfer: React.SVGProps<SVGFEComponentTransferElement>;
4141 feComposite: React.SVGProps<SVGFECompositeElement>;
4142 feConvolveMatrix: React.SVGProps<SVGFEConvolveMatrixElement>;
4143 feDiffuseLighting: React.SVGProps<SVGFEDiffuseLightingElement>;
4144 feDisplacementMap: React.SVGProps<SVGFEDisplacementMapElement>;
4145 feDistantLight: React.SVGProps<SVGFEDistantLightElement>;
4146 feDropShadow: React.SVGProps<SVGFEDropShadowElement>;
4147 feFlood: React.SVGProps<SVGFEFloodElement>;
4148 feFuncA: React.SVGProps<SVGFEFuncAElement>;
4149 feFuncB: React.SVGProps<SVGFEFuncBElement>;
4150 feFuncG: React.SVGProps<SVGFEFuncGElement>;
4151 feFuncR: React.SVGProps<SVGFEFuncRElement>;
4152 feGaussianBlur: React.SVGProps<SVGFEGaussianBlurElement>;
4153 feImage: React.SVGProps<SVGFEImageElement>;
4154 feMerge: React.SVGProps<SVGFEMergeElement>;
4155 feMergeNode: React.SVGProps<SVGFEMergeNodeElement>;
4156 feMorphology: React.SVGProps<SVGFEMorphologyElement>;
4157 feOffset: React.SVGProps<SVGFEOffsetElement>;
4158 fePointLight: React.SVGProps<SVGFEPointLightElement>;
4159 feSpecularLighting: React.SVGProps<SVGFESpecularLightingElement>;
4160 feSpotLight: React.SVGProps<SVGFESpotLightElement>;
4161 feTile: React.SVGProps<SVGFETileElement>;
4162 feTurbulence: React.SVGProps<SVGFETurbulenceElement>;
4163 filter: React.SVGProps<SVGFilterElement>;
4164 foreignObject: React.SVGProps<SVGForeignObjectElement>;
4165 g: React.SVGProps<SVGGElement>;
4166 image: React.SVGProps<SVGImageElement>;
4167 line: React.SVGLineElementAttributes<SVGLineElement>;
4168 linearGradient: React.SVGProps<SVGLinearGradientElement>;
4169 marker: React.SVGProps<SVGMarkerElement>;
4170 mask: React.SVGProps<SVGMaskElement>;
4171 metadata: React.SVGProps<SVGMetadataElement>;
4172 mpath: React.SVGProps<SVGElement>;
4173 path: React.SVGProps<SVGPathElement>;
4174 pattern: React.SVGProps<SVGPatternElement>;
4175 polygon: React.SVGProps<SVGPolygonElement>;
4176 polyline: React.SVGProps<SVGPolylineElement>;
4177 radialGradient: React.SVGProps<SVGRadialGradientElement>;
4178 rect: React.SVGProps<SVGRectElement>;
4179 set: React.SVGProps<SVGSetElement>;
4180 stop: React.SVGProps<SVGStopElement>;
4181 switch: React.SVGProps<SVGSwitchElement>;
4182 symbol: React.SVGProps<SVGSymbolElement>;
4183 text: React.SVGTextElementAttributes<SVGTextElement>;
4184 textPath: React.SVGProps<SVGTextPathElement>;
4185 tspan: React.SVGProps<SVGTSpanElement>;
4186 use: React.SVGProps<SVGUseElement>;
4187 view: React.SVGProps<SVGViewElement>;
4188 }
4189 }
4190}
4191
4192type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4193
4194// Any prop that has a default prop becomes optional, but its type is unchanged
4195// Undeclared default props are augmented into the resulting allowable attributes
4196// If declared props have indexed properties, ignore default props entirely as keyof gets widened
4197// Wrap in an outer-level conditional type to allow distribution over props that are unions
4198type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4199 :
4200 & Pick<P, Exclude<keyof P, keyof D>>
4201 & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4202 & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4203 : never;
4204
4205type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
4206 : P;
4207
\No newline at end of file