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)
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;
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.ElementRef<typeof MyComponent>;
1512 * ```
1513 *
1514 * @example
1515 *
1516 * ```tsx
1517 * type DivRef = React.ElementRef<'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 export function startTransition(scope: TransitionFunction): void;
1868
1869 /**
1870 * Wrap any code rendering and triggering updates to your components into `act()` calls.
1871 *
1872 * Ensures that the behavior in your tests matches what happens in the browser
1873 * more closely by executing pending `useEffect`s before returning. This also
1874 * reduces the amount of re-renders done.
1875 *
1876 * @param callback A synchronous, void callback that will execute as a single, complete React commit.
1877 *
1878 * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
1879 */
1880 // NOTES
1881 // - the order of these signatures matters - typescript will check the signatures in source order.
1882 // If the `() => VoidOrUndefinedOnly` signature is first, it'll erroneously match a Promise returning function for users with
1883 // `strictNullChecks: false`.
1884 // - VoidOrUndefinedOnly is there to forbid any non-void return values for users with `strictNullChecks: true`
1885 // 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.
1886 export function act(callback: () => VoidOrUndefinedOnly): void;
1887 export function act<T>(callback: () => T | Promise<T>): Promise<T>;
1888
1889 export function useId(): string;
1890
1891 /**
1892 * @param effect Imperative function that can return a cleanup function
1893 * @param deps If present, effect will only activate if the values in the list change.
1894 *
1895 * @see {@link https://github.com/facebook/react/pull/21913}
1896 */
1897 export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void;
1898
1899 /**
1900 * @param subscribe
1901 * @param getSnapshot
1902 *
1903 * @see {@link https://github.com/reactwg/react-18/discussions/86}
1904 */
1905 // keep in sync with `useSyncExternalStore` from `use-sync-external-store`
1906 export function useSyncExternalStore<Snapshot>(
1907 subscribe: (onStoreChange: () => void) => () => void,
1908 getSnapshot: () => Snapshot,
1909 getServerSnapshot?: () => Snapshot,
1910 ): Snapshot;
1911
1912 export function useOptimistic<State>(
1913 passthrough: State,
1914 ): [State, (action: State | ((pendingState: State) => State)) => void];
1915 export function useOptimistic<State, Action>(
1916 passthrough: State,
1917 reducer: (state: State, action: Action) => State,
1918 ): [State, (action: Action) => void];
1919
1920 export type Usable<T> = PromiseLike<T> | Context<T>;
1921
1922 export function use<T>(usable: Usable<T>): T;
1923
1924 export function useActionState<State>(
1925 action: (state: Awaited<State>) => State | Promise<State>,
1926 initialState: Awaited<State>,
1927 permalink?: string,
1928 ): [state: Awaited<State>, dispatch: () => void, isPending: boolean];
1929 export function useActionState<State, Payload>(
1930 action: (state: Awaited<State>, payload: Payload) => State | Promise<State>,
1931 initialState: Awaited<State>,
1932 permalink?: string,
1933 ): [state: Awaited<State>, dispatch: (payload: Payload) => void, isPending: boolean];
1934
1935 // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
1936 export function cache<CachedFunction extends Function>(fn: CachedFunction): CachedFunction;
1937
1938 //
1939 // Event System
1940 // ----------------------------------------------------------------------
1941 // TODO: change any to unknown when moving to TS v3
1942 interface BaseSyntheticEvent<E = object, C = any, T = any> {
1943 nativeEvent: E;
1944 currentTarget: C;
1945 target: T;
1946 bubbles: boolean;
1947 cancelable: boolean;
1948 defaultPrevented: boolean;
1949 eventPhase: number;
1950 isTrusted: boolean;
1951 preventDefault(): void;
1952 isDefaultPrevented(): boolean;
1953 stopPropagation(): void;
1954 isPropagationStopped(): boolean;
1955 persist(): void;
1956 timeStamp: number;
1957 type: string;
1958 }
1959
1960 /**
1961 * currentTarget - a reference to the element on which the event listener is registered.
1962 *
1963 * target - a reference to the element from which the event was originally dispatched.
1964 * This might be a child element to the element on which the event listener is registered.
1965 * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682
1966 */
1967 interface SyntheticEvent<T = Element, E = Event> extends BaseSyntheticEvent<E, EventTarget & T, EventTarget> {}
1968
1969 interface ClipboardEvent<T = Element> extends SyntheticEvent<T, NativeClipboardEvent> {
1970 clipboardData: DataTransfer;
1971 }
1972
1973 interface CompositionEvent<T = Element> extends SyntheticEvent<T, NativeCompositionEvent> {
1974 data: string;
1975 }
1976
1977 interface DragEvent<T = Element> extends MouseEvent<T, NativeDragEvent> {
1978 dataTransfer: DataTransfer;
1979 }
1980
1981 interface PointerEvent<T = Element> extends MouseEvent<T, NativePointerEvent> {
1982 pointerId: number;
1983 pressure: number;
1984 tangentialPressure: number;
1985 tiltX: number;
1986 tiltY: number;
1987 twist: number;
1988 width: number;
1989 height: number;
1990 pointerType: "mouse" | "pen" | "touch";
1991 isPrimary: boolean;
1992 }
1993
1994 interface FocusEvent<Target = Element, RelatedTarget = Element> extends SyntheticEvent<Target, NativeFocusEvent> {
1995 relatedTarget: (EventTarget & RelatedTarget) | null;
1996 target: EventTarget & Target;
1997 }
1998
1999 interface FormEvent<T = Element> extends SyntheticEvent<T> {
2000 }
2001
2002 interface InvalidEvent<T = Element> extends SyntheticEvent<T> {
2003 target: EventTarget & T;
2004 }
2005
2006 interface ChangeEvent<T = Element> extends SyntheticEvent<T> {
2007 target: EventTarget & T;
2008 }
2009
2010 export type ModifierKey =
2011 | "Alt"
2012 | "AltGraph"
2013 | "CapsLock"
2014 | "Control"
2015 | "Fn"
2016 | "FnLock"
2017 | "Hyper"
2018 | "Meta"
2019 | "NumLock"
2020 | "ScrollLock"
2021 | "Shift"
2022 | "Super"
2023 | "Symbol"
2024 | "SymbolLock";
2025
2026 interface KeyboardEvent<T = Element> extends UIEvent<T, NativeKeyboardEvent> {
2027 altKey: boolean;
2028 /** @deprecated */
2029 charCode: number;
2030 ctrlKey: boolean;
2031 code: string;
2032 /**
2033 * 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.
2034 */
2035 getModifierState(key: ModifierKey): boolean;
2036 /**
2037 * See the [DOM Level 3 Events spec](https://www.w3.org/TR/uievents-key/#named-key-attribute-values). for possible values
2038 */
2039 key: string;
2040 /** @deprecated */
2041 keyCode: number;
2042 locale: string;
2043 location: number;
2044 metaKey: boolean;
2045 repeat: boolean;
2046 shiftKey: boolean;
2047 /** @deprecated */
2048 which: number;
2049 }
2050
2051 interface MouseEvent<T = Element, E = NativeMouseEvent> extends UIEvent<T, E> {
2052 altKey: boolean;
2053 button: number;
2054 buttons: number;
2055 clientX: number;
2056 clientY: number;
2057 ctrlKey: boolean;
2058 /**
2059 * 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.
2060 */
2061 getModifierState(key: ModifierKey): boolean;
2062 metaKey: boolean;
2063 movementX: number;
2064 movementY: number;
2065 pageX: number;
2066 pageY: number;
2067 relatedTarget: EventTarget | null;
2068 screenX: number;
2069 screenY: number;
2070 shiftKey: boolean;
2071 }
2072
2073 interface TouchEvent<T = Element> extends UIEvent<T, NativeTouchEvent> {
2074 altKey: boolean;
2075 changedTouches: TouchList;
2076 ctrlKey: boolean;
2077 /**
2078 * 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.
2079 */
2080 getModifierState(key: ModifierKey): boolean;
2081 metaKey: boolean;
2082 shiftKey: boolean;
2083 targetTouches: TouchList;
2084 touches: TouchList;
2085 }
2086
2087 interface UIEvent<T = Element, E = NativeUIEvent> extends SyntheticEvent<T, E> {
2088 detail: number;
2089 view: AbstractView;
2090 }
2091
2092 interface WheelEvent<T = Element> extends MouseEvent<T, NativeWheelEvent> {
2093 deltaMode: number;
2094 deltaX: number;
2095 deltaY: number;
2096 deltaZ: number;
2097 }
2098
2099 interface AnimationEvent<T = Element> extends SyntheticEvent<T, NativeAnimationEvent> {
2100 animationName: string;
2101 elapsedTime: number;
2102 pseudoElement: string;
2103 }
2104
2105 interface ToggleEvent<T = Element> extends SyntheticEvent<T, NativeToggleEvent> {
2106 oldState: "closed" | "open";
2107 newState: "closed" | "open";
2108 }
2109
2110 interface TransitionEvent<T = Element> extends SyntheticEvent<T, NativeTransitionEvent> {
2111 elapsedTime: number;
2112 propertyName: string;
2113 pseudoElement: string;
2114 }
2115
2116 //
2117 // Event Handler Types
2118 // ----------------------------------------------------------------------
2119
2120 type EventHandler<E extends SyntheticEvent<any>> = { bivarianceHack(event: E): void }["bivarianceHack"];
2121
2122 type ReactEventHandler<T = Element> = EventHandler<SyntheticEvent<T>>;
2123
2124 type ClipboardEventHandler<T = Element> = EventHandler<ClipboardEvent<T>>;
2125 type CompositionEventHandler<T = Element> = EventHandler<CompositionEvent<T>>;
2126 type DragEventHandler<T = Element> = EventHandler<DragEvent<T>>;
2127 type FocusEventHandler<T = Element> = EventHandler<FocusEvent<T>>;
2128 type FormEventHandler<T = Element> = EventHandler<FormEvent<T>>;
2129 type ChangeEventHandler<T = Element> = EventHandler<ChangeEvent<T>>;
2130 type KeyboardEventHandler<T = Element> = EventHandler<KeyboardEvent<T>>;
2131 type MouseEventHandler<T = Element> = EventHandler<MouseEvent<T>>;
2132 type TouchEventHandler<T = Element> = EventHandler<TouchEvent<T>>;
2133 type PointerEventHandler<T = Element> = EventHandler<PointerEvent<T>>;
2134 type UIEventHandler<T = Element> = EventHandler<UIEvent<T>>;
2135 type WheelEventHandler<T = Element> = EventHandler<WheelEvent<T>>;
2136 type AnimationEventHandler<T = Element> = EventHandler<AnimationEvent<T>>;
2137 type ToggleEventHandler<T = Element> = EventHandler<ToggleEvent<T>>;
2138 type TransitionEventHandler<T = Element> = EventHandler<TransitionEvent<T>>;
2139
2140 //
2141 // Props / DOM Attributes
2142 // ----------------------------------------------------------------------
2143
2144 interface HTMLProps<T> extends AllHTMLAttributes<T>, ClassAttributes<T> {
2145 }
2146
2147 type DetailedHTMLProps<E extends HTMLAttributes<T>, T> = ClassAttributes<T> & E;
2148
2149 interface SVGProps<T> extends SVGAttributes<T>, ClassAttributes<T> {
2150 }
2151
2152 interface SVGLineElementAttributes<T> extends SVGProps<T> {}
2153 interface SVGTextElementAttributes<T> extends SVGProps<T> {}
2154
2155 interface DOMAttributes<T> {
2156 children?: ReactNode | undefined;
2157 dangerouslySetInnerHTML?: {
2158 // Should be InnerHTML['innerHTML'].
2159 // But unfortunately we're mixing renderer-specific type declarations.
2160 __html: string | TrustedHTML;
2161 } | undefined;
2162
2163 // Clipboard Events
2164 onCopy?: ClipboardEventHandler<T> | undefined;
2165 onCopyCapture?: ClipboardEventHandler<T> | undefined;
2166 onCut?: ClipboardEventHandler<T> | undefined;
2167 onCutCapture?: ClipboardEventHandler<T> | undefined;
2168 onPaste?: ClipboardEventHandler<T> | undefined;
2169 onPasteCapture?: ClipboardEventHandler<T> | undefined;
2170
2171 // Composition Events
2172 onCompositionEnd?: CompositionEventHandler<T> | undefined;
2173 onCompositionEndCapture?: CompositionEventHandler<T> | undefined;
2174 onCompositionStart?: CompositionEventHandler<T> | undefined;
2175 onCompositionStartCapture?: CompositionEventHandler<T> | undefined;
2176 onCompositionUpdate?: CompositionEventHandler<T> | undefined;
2177 onCompositionUpdateCapture?: CompositionEventHandler<T> | undefined;
2178
2179 // Focus Events
2180 onFocus?: FocusEventHandler<T> | undefined;
2181 onFocusCapture?: FocusEventHandler<T> | undefined;
2182 onBlur?: FocusEventHandler<T> | undefined;
2183 onBlurCapture?: FocusEventHandler<T> | undefined;
2184
2185 // Form Events
2186 onChange?: FormEventHandler<T> | undefined;
2187 onChangeCapture?: FormEventHandler<T> | undefined;
2188 onBeforeInput?: FormEventHandler<T> | undefined;
2189 onBeforeInputCapture?: FormEventHandler<T> | undefined;
2190 onInput?: FormEventHandler<T> | undefined;
2191 onInputCapture?: FormEventHandler<T> | undefined;
2192 onReset?: FormEventHandler<T> | undefined;
2193 onResetCapture?: FormEventHandler<T> | undefined;
2194 onSubmit?: FormEventHandler<T> | undefined;
2195 onSubmitCapture?: FormEventHandler<T> | undefined;
2196 onInvalid?: FormEventHandler<T> | undefined;
2197 onInvalidCapture?: FormEventHandler<T> | undefined;
2198
2199 // Image Events
2200 onLoad?: ReactEventHandler<T> | undefined;
2201 onLoadCapture?: ReactEventHandler<T> | undefined;
2202 onError?: ReactEventHandler<T> | undefined; // also a Media Event
2203 onErrorCapture?: ReactEventHandler<T> | undefined; // also a Media Event
2204
2205 // Keyboard Events
2206 onKeyDown?: KeyboardEventHandler<T> | undefined;
2207 onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
2208 /** @deprecated Use `onKeyUp` or `onKeyDown` instead */
2209 onKeyPress?: KeyboardEventHandler<T> | undefined;
2210 /** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
2211 onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
2212 onKeyUp?: KeyboardEventHandler<T> | undefined;
2213 onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
2214
2215 // Media Events
2216 onAbort?: ReactEventHandler<T> | undefined;
2217 onAbortCapture?: ReactEventHandler<T> | undefined;
2218 onCanPlay?: ReactEventHandler<T> | undefined;
2219 onCanPlayCapture?: ReactEventHandler<T> | undefined;
2220 onCanPlayThrough?: ReactEventHandler<T> | undefined;
2221 onCanPlayThroughCapture?: ReactEventHandler<T> | undefined;
2222 onDurationChange?: ReactEventHandler<T> | undefined;
2223 onDurationChangeCapture?: ReactEventHandler<T> | undefined;
2224 onEmptied?: ReactEventHandler<T> | undefined;
2225 onEmptiedCapture?: ReactEventHandler<T> | undefined;
2226 onEncrypted?: ReactEventHandler<T> | undefined;
2227 onEncryptedCapture?: ReactEventHandler<T> | undefined;
2228 onEnded?: ReactEventHandler<T> | undefined;
2229 onEndedCapture?: ReactEventHandler<T> | undefined;
2230 onLoadedData?: ReactEventHandler<T> | undefined;
2231 onLoadedDataCapture?: ReactEventHandler<T> | undefined;
2232 onLoadedMetadata?: ReactEventHandler<T> | undefined;
2233 onLoadedMetadataCapture?: ReactEventHandler<T> | undefined;
2234 onLoadStart?: ReactEventHandler<T> | undefined;
2235 onLoadStartCapture?: ReactEventHandler<T> | undefined;
2236 onPause?: ReactEventHandler<T> | undefined;
2237 onPauseCapture?: ReactEventHandler<T> | undefined;
2238 onPlay?: ReactEventHandler<T> | undefined;
2239 onPlayCapture?: ReactEventHandler<T> | undefined;
2240 onPlaying?: ReactEventHandler<T> | undefined;
2241 onPlayingCapture?: ReactEventHandler<T> | undefined;
2242 onProgress?: ReactEventHandler<T> | undefined;
2243 onProgressCapture?: ReactEventHandler<T> | undefined;
2244 onRateChange?: ReactEventHandler<T> | undefined;
2245 onRateChangeCapture?: ReactEventHandler<T> | undefined;
2246 onResize?: ReactEventHandler<T> | undefined;
2247 onResizeCapture?: ReactEventHandler<T> | undefined;
2248 onSeeked?: ReactEventHandler<T> | undefined;
2249 onSeekedCapture?: ReactEventHandler<T> | undefined;
2250 onSeeking?: ReactEventHandler<T> | undefined;
2251 onSeekingCapture?: ReactEventHandler<T> | undefined;
2252 onStalled?: ReactEventHandler<T> | undefined;
2253 onStalledCapture?: ReactEventHandler<T> | undefined;
2254 onSuspend?: ReactEventHandler<T> | undefined;
2255 onSuspendCapture?: ReactEventHandler<T> | undefined;
2256 onTimeUpdate?: ReactEventHandler<T> | undefined;
2257 onTimeUpdateCapture?: ReactEventHandler<T> | undefined;
2258 onVolumeChange?: ReactEventHandler<T> | undefined;
2259 onVolumeChangeCapture?: ReactEventHandler<T> | undefined;
2260 onWaiting?: ReactEventHandler<T> | undefined;
2261 onWaitingCapture?: ReactEventHandler<T> | undefined;
2262
2263 // MouseEvents
2264 onAuxClick?: MouseEventHandler<T> | undefined;
2265 onAuxClickCapture?: MouseEventHandler<T> | undefined;
2266 onClick?: MouseEventHandler<T> | undefined;
2267 onClickCapture?: MouseEventHandler<T> | undefined;
2268 onContextMenu?: MouseEventHandler<T> | undefined;
2269 onContextMenuCapture?: MouseEventHandler<T> | undefined;
2270 onDoubleClick?: MouseEventHandler<T> | undefined;
2271 onDoubleClickCapture?: MouseEventHandler<T> | undefined;
2272 onDrag?: DragEventHandler<T> | undefined;
2273 onDragCapture?: DragEventHandler<T> | undefined;
2274 onDragEnd?: DragEventHandler<T> | undefined;
2275 onDragEndCapture?: DragEventHandler<T> | undefined;
2276 onDragEnter?: DragEventHandler<T> | undefined;
2277 onDragEnterCapture?: DragEventHandler<T> | undefined;
2278 onDragExit?: DragEventHandler<T> | undefined;
2279 onDragExitCapture?: DragEventHandler<T> | undefined;
2280 onDragLeave?: DragEventHandler<T> | undefined;
2281 onDragLeaveCapture?: DragEventHandler<T> | undefined;
2282 onDragOver?: DragEventHandler<T> | undefined;
2283 onDragOverCapture?: DragEventHandler<T> | undefined;
2284 onDragStart?: DragEventHandler<T> | undefined;
2285 onDragStartCapture?: DragEventHandler<T> | undefined;
2286 onDrop?: DragEventHandler<T> | undefined;
2287 onDropCapture?: DragEventHandler<T> | undefined;
2288 onMouseDown?: MouseEventHandler<T> | undefined;
2289 onMouseDownCapture?: MouseEventHandler<T> | undefined;
2290 onMouseEnter?: MouseEventHandler<T> | undefined;
2291 onMouseLeave?: MouseEventHandler<T> | undefined;
2292 onMouseMove?: MouseEventHandler<T> | undefined;
2293 onMouseMoveCapture?: MouseEventHandler<T> | undefined;
2294 onMouseOut?: MouseEventHandler<T> | undefined;
2295 onMouseOutCapture?: MouseEventHandler<T> | undefined;
2296 onMouseOver?: MouseEventHandler<T> | undefined;
2297 onMouseOverCapture?: MouseEventHandler<T> | undefined;
2298 onMouseUp?: MouseEventHandler<T> | undefined;
2299 onMouseUpCapture?: MouseEventHandler<T> | undefined;
2300
2301 // Selection Events
2302 onSelect?: ReactEventHandler<T> | undefined;
2303 onSelectCapture?: ReactEventHandler<T> | undefined;
2304
2305 // Touch Events
2306 onTouchCancel?: TouchEventHandler<T> | undefined;
2307 onTouchCancelCapture?: TouchEventHandler<T> | undefined;
2308 onTouchEnd?: TouchEventHandler<T> | undefined;
2309 onTouchEndCapture?: TouchEventHandler<T> | undefined;
2310 onTouchMove?: TouchEventHandler<T> | undefined;
2311 onTouchMoveCapture?: TouchEventHandler<T> | undefined;
2312 onTouchStart?: TouchEventHandler<T> | undefined;
2313 onTouchStartCapture?: TouchEventHandler<T> | undefined;
2314
2315 // Pointer Events
2316 onPointerDown?: PointerEventHandler<T> | undefined;
2317 onPointerDownCapture?: PointerEventHandler<T> | undefined;
2318 onPointerMove?: PointerEventHandler<T> | undefined;
2319 onPointerMoveCapture?: PointerEventHandler<T> | undefined;
2320 onPointerUp?: PointerEventHandler<T> | undefined;
2321 onPointerUpCapture?: PointerEventHandler<T> | undefined;
2322 onPointerCancel?: PointerEventHandler<T> | undefined;
2323 onPointerCancelCapture?: PointerEventHandler<T> | undefined;
2324 onPointerEnter?: PointerEventHandler<T> | undefined;
2325 onPointerLeave?: PointerEventHandler<T> | undefined;
2326 onPointerOver?: PointerEventHandler<T> | undefined;
2327 onPointerOverCapture?: PointerEventHandler<T> | undefined;
2328 onPointerOut?: PointerEventHandler<T> | undefined;
2329 onPointerOutCapture?: PointerEventHandler<T> | undefined;
2330 onGotPointerCapture?: PointerEventHandler<T> | undefined;
2331 onGotPointerCaptureCapture?: PointerEventHandler<T> | undefined;
2332 onLostPointerCapture?: PointerEventHandler<T> | undefined;
2333 onLostPointerCaptureCapture?: PointerEventHandler<T> | undefined;
2334
2335 // UI Events
2336 onScroll?: UIEventHandler<T> | undefined;
2337 onScrollCapture?: UIEventHandler<T> | undefined;
2338
2339 // Wheel Events
2340 onWheel?: WheelEventHandler<T> | undefined;
2341 onWheelCapture?: WheelEventHandler<T> | undefined;
2342
2343 // Animation Events
2344 onAnimationStart?: AnimationEventHandler<T> | undefined;
2345 onAnimationStartCapture?: AnimationEventHandler<T> | undefined;
2346 onAnimationEnd?: AnimationEventHandler<T> | undefined;
2347 onAnimationEndCapture?: AnimationEventHandler<T> | undefined;
2348 onAnimationIteration?: AnimationEventHandler<T> | undefined;
2349 onAnimationIterationCapture?: AnimationEventHandler<T> | undefined;
2350
2351 // Toggle Events
2352 onToggle?: ToggleEventHandler<T> | undefined;
2353 onBeforeToggle?: ToggleEventHandler<T> | undefined;
2354
2355 // Transition Events
2356 onTransitionCancel?: TransitionEventHandler<T> | undefined;
2357 onTransitionCancelCapture?: TransitionEventHandler<T> | undefined;
2358 onTransitionEnd?: TransitionEventHandler<T> | undefined;
2359 onTransitionEndCapture?: TransitionEventHandler<T> | undefined;
2360 onTransitionRun?: TransitionEventHandler<T> | undefined;
2361 onTransitionRunCapture?: TransitionEventHandler<T> | undefined;
2362 onTransitionStart?: TransitionEventHandler<T> | undefined;
2363 onTransitionStartCapture?: TransitionEventHandler<T> | undefined;
2364 }
2365
2366 export interface CSSProperties extends CSS.Properties<string | number> {
2367 /**
2368 * The index signature was removed to enable closed typing for style
2369 * using CSSType. You're able to use type assertion or module augmentation
2370 * to add properties or an index signature of your own.
2371 *
2372 * For examples and more information, visit:
2373 * https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
2374 */
2375 }
2376
2377 // All the WAI-ARIA 1.1 attributes from https://www.w3.org/TR/wai-aria-1.1/
2378 interface AriaAttributes {
2379 /** Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application. */
2380 "aria-activedescendant"?: string | undefined;
2381 /** 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. */
2382 "aria-atomic"?: Booleanish | undefined;
2383 /**
2384 * 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
2385 * presented if they are made.
2386 */
2387 "aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
2388 /** 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. */
2389 /**
2390 * Defines a string value that labels the current element, which is intended to be converted into Braille.
2391 * @see aria-label.
2392 */
2393 "aria-braillelabel"?: string | undefined;
2394 /**
2395 * Defines a human-readable, author-localized abbreviated description for the role of an element, which is intended to be converted into Braille.
2396 * @see aria-roledescription.
2397 */
2398 "aria-brailleroledescription"?: string | undefined;
2399 "aria-busy"?: Booleanish | undefined;
2400 /**
2401 * Indicates the current "checked" state of checkboxes, radio buttons, and other widgets.
2402 * @see aria-pressed @see aria-selected.
2403 */
2404 "aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
2405 /**
2406 * Defines the total number of columns in a table, grid, or treegrid.
2407 * @see aria-colindex.
2408 */
2409 "aria-colcount"?: number | undefined;
2410 /**
2411 * Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.
2412 * @see aria-colcount @see aria-colspan.
2413 */
2414 "aria-colindex"?: number | undefined;
2415 /**
2416 * Defines a human readable text alternative of aria-colindex.
2417 * @see aria-rowindextext.
2418 */
2419 "aria-colindextext"?: string | undefined;
2420 /**
2421 * Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.
2422 * @see aria-colindex @see aria-rowspan.
2423 */
2424 "aria-colspan"?: number | undefined;
2425 /**
2426 * Identifies the element (or elements) whose contents or presence are controlled by the current element.
2427 * @see aria-owns.
2428 */
2429 "aria-controls"?: string | undefined;
2430 /** Indicates the element that represents the current item within a container or set of related elements. */
2431 "aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
2432 /**
2433 * Identifies the element (or elements) that describes the object.
2434 * @see aria-labelledby
2435 */
2436 "aria-describedby"?: string | undefined;
2437 /**
2438 * Defines a string value that describes or annotates the current element.
2439 * @see related aria-describedby.
2440 */
2441 "aria-description"?: string | undefined;
2442 /**
2443 * Identifies the element that provides a detailed, extended description for the object.
2444 * @see aria-describedby.
2445 */
2446 "aria-details"?: string | undefined;
2447 /**
2448 * Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.
2449 * @see aria-hidden @see aria-readonly.
2450 */
2451 "aria-disabled"?: Booleanish | undefined;
2452 /**
2453 * Indicates what functions can be performed when a dragged object is released on the drop target.
2454 * @deprecated in ARIA 1.1
2455 */
2456 "aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
2457 /**
2458 * Identifies the element that provides an error message for the object.
2459 * @see aria-invalid @see aria-describedby.
2460 */
2461 "aria-errormessage"?: string | undefined;
2462 /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
2463 "aria-expanded"?: Booleanish | undefined;
2464 /**
2465 * Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,
2466 * allows assistive technology to override the general default of reading in document source order.
2467 */
2468 "aria-flowto"?: string | undefined;
2469 /**
2470 * Indicates an element's "grabbed" state in a drag-and-drop operation.
2471 * @deprecated in ARIA 1.1
2472 */
2473 "aria-grabbed"?: Booleanish | undefined;
2474 /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
2475 "aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
2476 /**
2477 * Indicates whether the element is exposed to an accessibility API.
2478 * @see aria-disabled.
2479 */
2480 "aria-hidden"?: Booleanish | undefined;
2481 /**
2482 * Indicates the entered value does not conform to the format expected by the application.
2483 * @see aria-errormessage.
2484 */
2485 "aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
2486 /** Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element. */
2487 "aria-keyshortcuts"?: string | undefined;
2488 /**
2489 * Defines a string value that labels the current element.
2490 * @see aria-labelledby.
2491 */
2492 "aria-label"?: string | undefined;
2493 /**
2494 * Identifies the element (or elements) that labels the current element.
2495 * @see aria-describedby.
2496 */
2497 "aria-labelledby"?: string | undefined;
2498 /** Defines the hierarchical level of an element within a structure. */
2499 "aria-level"?: number | undefined;
2500 /** 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. */
2501 "aria-live"?: "off" | "assertive" | "polite" | undefined;
2502 /** Indicates whether an element is modal when displayed. */
2503 "aria-modal"?: Booleanish | undefined;
2504 /** Indicates whether a text box accepts multiple lines of input or only a single line. */
2505 "aria-multiline"?: Booleanish | undefined;
2506 /** Indicates that the user may select more than one item from the current selectable descendants. */
2507 "aria-multiselectable"?: Booleanish | undefined;
2508 /** Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous. */
2509 "aria-orientation"?: "horizontal" | "vertical" | undefined;
2510 /**
2511 * Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship
2512 * between DOM elements where the DOM hierarchy cannot be used to represent the relationship.
2513 * @see aria-controls.
2514 */
2515 "aria-owns"?: string | undefined;
2516 /**
2517 * Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.
2518 * A hint could be a sample value or a brief description of the expected format.
2519 */
2520 "aria-placeholder"?: string | undefined;
2521 /**
2522 * 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.
2523 * @see aria-setsize.
2524 */
2525 "aria-posinset"?: number | undefined;
2526 /**
2527 * Indicates the current "pressed" state of toggle buttons.
2528 * @see aria-checked @see aria-selected.
2529 */
2530 "aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
2531 /**
2532 * Indicates that the element is not editable, but is otherwise operable.
2533 * @see aria-disabled.
2534 */
2535 "aria-readonly"?: Booleanish | undefined;
2536 /**
2537 * Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.
2538 * @see aria-atomic.
2539 */
2540 "aria-relevant"?:
2541 | "additions"
2542 | "additions removals"
2543 | "additions text"
2544 | "all"
2545 | "removals"
2546 | "removals additions"
2547 | "removals text"
2548 | "text"
2549 | "text additions"
2550 | "text removals"
2551 | undefined;
2552 /** Indicates that user input is required on the element before a form may be submitted. */
2553 "aria-required"?: Booleanish | undefined;
2554 /** Defines a human-readable, author-localized description for the role of an element. */
2555 "aria-roledescription"?: string | undefined;
2556 /**
2557 * Defines the total number of rows in a table, grid, or treegrid.
2558 * @see aria-rowindex.
2559 */
2560 "aria-rowcount"?: number | undefined;
2561 /**
2562 * Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.
2563 * @see aria-rowcount @see aria-rowspan.
2564 */
2565 "aria-rowindex"?: number | undefined;
2566 /**
2567 * Defines a human readable text alternative of aria-rowindex.
2568 * @see aria-colindextext.
2569 */
2570 "aria-rowindextext"?: string | undefined;
2571 /**
2572 * Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.
2573 * @see aria-rowindex @see aria-colspan.
2574 */
2575 "aria-rowspan"?: number | undefined;
2576 /**
2577 * Indicates the current "selected" state of various widgets.
2578 * @see aria-checked @see aria-pressed.
2579 */
2580 "aria-selected"?: Booleanish | undefined;
2581 /**
2582 * 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.
2583 * @see aria-posinset.
2584 */
2585 "aria-setsize"?: number | undefined;
2586 /** Indicates if items in a table or grid are sorted in ascending or descending order. */
2587 "aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
2588 /** Defines the maximum allowed value for a range widget. */
2589 "aria-valuemax"?: number | undefined;
2590 /** Defines the minimum allowed value for a range widget. */
2591 "aria-valuemin"?: number | undefined;
2592 /**
2593 * Defines the current value for a range widget.
2594 * @see aria-valuetext.
2595 */
2596 "aria-valuenow"?: number | undefined;
2597 /** Defines the human readable text alternative of aria-valuenow for a range widget. */
2598 "aria-valuetext"?: string | undefined;
2599 }
2600
2601 // All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
2602 type AriaRole =
2603 | "alert"
2604 | "alertdialog"
2605 | "application"
2606 | "article"
2607 | "banner"
2608 | "button"
2609 | "cell"
2610 | "checkbox"
2611 | "columnheader"
2612 | "combobox"
2613 | "complementary"
2614 | "contentinfo"
2615 | "definition"
2616 | "dialog"
2617 | "directory"
2618 | "document"
2619 | "feed"
2620 | "figure"
2621 | "form"
2622 | "grid"
2623 | "gridcell"
2624 | "group"
2625 | "heading"
2626 | "img"
2627 | "link"
2628 | "list"
2629 | "listbox"
2630 | "listitem"
2631 | "log"
2632 | "main"
2633 | "marquee"
2634 | "math"
2635 | "menu"
2636 | "menubar"
2637 | "menuitem"
2638 | "menuitemcheckbox"
2639 | "menuitemradio"
2640 | "navigation"
2641 | "none"
2642 | "note"
2643 | "option"
2644 | "presentation"
2645 | "progressbar"
2646 | "radio"
2647 | "radiogroup"
2648 | "region"
2649 | "row"
2650 | "rowgroup"
2651 | "rowheader"
2652 | "scrollbar"
2653 | "search"
2654 | "searchbox"
2655 | "separator"
2656 | "slider"
2657 | "spinbutton"
2658 | "status"
2659 | "switch"
2660 | "tab"
2661 | "table"
2662 | "tablist"
2663 | "tabpanel"
2664 | "term"
2665 | "textbox"
2666 | "timer"
2667 | "toolbar"
2668 | "tooltip"
2669 | "tree"
2670 | "treegrid"
2671 | "treeitem"
2672 | (string & {});
2673
2674 interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
2675 // React-specific Attributes
2676 defaultChecked?: boolean | undefined;
2677 defaultValue?: string | number | readonly string[] | undefined;
2678 suppressContentEditableWarning?: boolean | undefined;
2679 suppressHydrationWarning?: boolean | undefined;
2680
2681 // Standard HTML Attributes
2682 accessKey?: string | undefined;
2683 autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {});
2684 autoFocus?: boolean | undefined;
2685 className?: string | undefined;
2686 contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
2687 contextMenu?: string | undefined;
2688 dir?: string | undefined;
2689 draggable?: Booleanish | undefined;
2690 enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
2691 hidden?: boolean | undefined;
2692 id?: string | undefined;
2693 lang?: string | undefined;
2694 nonce?: string | undefined;
2695 slot?: string | undefined;
2696 spellCheck?: Booleanish | undefined;
2697 style?: CSSProperties | undefined;
2698 tabIndex?: number | undefined;
2699 title?: string | undefined;
2700 translate?: "yes" | "no" | undefined;
2701
2702 // Unknown
2703 radioGroup?: string | undefined; // <command>, <menuitem>
2704
2705 // WAI-ARIA
2706 role?: AriaRole | undefined;
2707
2708 // RDFa Attributes
2709 about?: string | undefined;
2710 content?: string | undefined;
2711 datatype?: string | undefined;
2712 inlist?: any;
2713 prefix?: string | undefined;
2714 property?: string | undefined;
2715 rel?: string | undefined;
2716 resource?: string | undefined;
2717 rev?: string | undefined;
2718 typeof?: string | undefined;
2719 vocab?: string | undefined;
2720
2721 // Non-standard Attributes
2722 autoCorrect?: string | undefined;
2723 autoSave?: string | undefined;
2724 color?: string | undefined;
2725 itemProp?: string | undefined;
2726 itemScope?: boolean | undefined;
2727 itemType?: string | undefined;
2728 itemID?: string | undefined;
2729 itemRef?: string | undefined;
2730 results?: number | undefined;
2731 security?: string | undefined;
2732 unselectable?: "on" | "off" | undefined;
2733
2734 // Popover API
2735 popover?: "" | "auto" | "manual" | undefined;
2736 popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
2737 popoverTarget?: string | undefined;
2738
2739 // Living Standard
2740 /**
2741 * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert
2742 */
2743 inert?: boolean | undefined;
2744 /**
2745 * Hints at the type of data that might be entered by the user while editing the element or its contents
2746 * @see {@link https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute}
2747 */
2748 inputMode?: "none" | "text" | "tel" | "url" | "email" | "numeric" | "decimal" | "search" | undefined;
2749 /**
2750 * Specify that a standard HTML element should behave like a defined custom built-in element
2751 * @see {@link https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is}
2752 */
2753 is?: string | undefined;
2754 }
2755
2756 /**
2757 * For internal usage only.
2758 * Different release channels declare additional types of ReactNode this particular release channel accepts.
2759 * App or library types should never augment this interface.
2760 */
2761 interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {}
2762
2763 interface AllHTMLAttributes<T> extends HTMLAttributes<T> {
2764 // Standard HTML Attributes
2765 accept?: string | undefined;
2766 acceptCharset?: string | undefined;
2767 action?:
2768 | string
2769 | undefined
2770 | ((formData: FormData) => void | Promise<void>)
2771 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2772 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2773 ];
2774 allowFullScreen?: boolean | undefined;
2775 allowTransparency?: boolean | undefined;
2776 alt?: string | undefined;
2777 as?: string | undefined;
2778 async?: boolean | undefined;
2779 autoComplete?: string | undefined;
2780 autoPlay?: boolean | undefined;
2781 capture?: boolean | "user" | "environment" | undefined;
2782 cellPadding?: number | string | undefined;
2783 cellSpacing?: number | string | undefined;
2784 charSet?: string | undefined;
2785 challenge?: string | undefined;
2786 checked?: boolean | undefined;
2787 cite?: string | undefined;
2788 classID?: string | undefined;
2789 cols?: number | undefined;
2790 colSpan?: number | undefined;
2791 controls?: boolean | undefined;
2792 coords?: string | undefined;
2793 crossOrigin?: CrossOrigin;
2794 data?: string | undefined;
2795 dateTime?: string | undefined;
2796 default?: boolean | undefined;
2797 defer?: boolean | undefined;
2798 disabled?: boolean | undefined;
2799 download?: any;
2800 encType?: string | undefined;
2801 form?: string | undefined;
2802 formAction?:
2803 | string
2804 | undefined
2805 | ((formData: FormData) => void | Promise<void>)
2806 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2807 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2808 ];
2809 formEncType?: string | undefined;
2810 formMethod?: string | undefined;
2811 formNoValidate?: boolean | undefined;
2812 formTarget?: string | undefined;
2813 frameBorder?: number | string | undefined;
2814 headers?: string | undefined;
2815 height?: number | string | undefined;
2816 high?: number | undefined;
2817 href?: string | undefined;
2818 hrefLang?: string | undefined;
2819 htmlFor?: string | undefined;
2820 httpEquiv?: string | undefined;
2821 integrity?: string | undefined;
2822 keyParams?: string | undefined;
2823 keyType?: string | undefined;
2824 kind?: string | undefined;
2825 label?: string | undefined;
2826 list?: string | undefined;
2827 loop?: boolean | undefined;
2828 low?: number | undefined;
2829 manifest?: string | undefined;
2830 marginHeight?: number | undefined;
2831 marginWidth?: number | undefined;
2832 max?: number | string | undefined;
2833 maxLength?: number | undefined;
2834 media?: string | undefined;
2835 mediaGroup?: string | undefined;
2836 method?: string | undefined;
2837 min?: number | string | undefined;
2838 minLength?: number | undefined;
2839 multiple?: boolean | undefined;
2840 muted?: boolean | undefined;
2841 name?: string | undefined;
2842 noValidate?: boolean | undefined;
2843 open?: boolean | undefined;
2844 optimum?: number | undefined;
2845 pattern?: string | undefined;
2846 placeholder?: string | undefined;
2847 playsInline?: boolean | undefined;
2848 poster?: string | undefined;
2849 preload?: string | undefined;
2850 readOnly?: boolean | undefined;
2851 required?: boolean | undefined;
2852 reversed?: boolean | undefined;
2853 rows?: number | undefined;
2854 rowSpan?: number | undefined;
2855 sandbox?: string | undefined;
2856 scope?: string | undefined;
2857 scoped?: boolean | undefined;
2858 scrolling?: string | undefined;
2859 seamless?: boolean | undefined;
2860 selected?: boolean | undefined;
2861 shape?: string | undefined;
2862 size?: number | undefined;
2863 sizes?: string | undefined;
2864 span?: number | undefined;
2865 src?: string | undefined;
2866 srcDoc?: string | undefined;
2867 srcLang?: string | undefined;
2868 srcSet?: string | undefined;
2869 start?: number | undefined;
2870 step?: number | string | undefined;
2871 summary?: string | undefined;
2872 target?: string | undefined;
2873 type?: string | undefined;
2874 useMap?: string | undefined;
2875 value?: string | readonly string[] | number | undefined;
2876 width?: number | string | undefined;
2877 wmode?: string | undefined;
2878 wrap?: string | undefined;
2879 }
2880
2881 type HTMLAttributeReferrerPolicy =
2882 | ""
2883 | "no-referrer"
2884 | "no-referrer-when-downgrade"
2885 | "origin"
2886 | "origin-when-cross-origin"
2887 | "same-origin"
2888 | "strict-origin"
2889 | "strict-origin-when-cross-origin"
2890 | "unsafe-url";
2891
2892 type HTMLAttributeAnchorTarget =
2893 | "_self"
2894 | "_blank"
2895 | "_parent"
2896 | "_top"
2897 | (string & {});
2898
2899 interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
2900 download?: any;
2901 href?: string | undefined;
2902 hrefLang?: string | undefined;
2903 media?: string | undefined;
2904 ping?: string | undefined;
2905 target?: HTMLAttributeAnchorTarget | undefined;
2906 type?: string | undefined;
2907 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2908 }
2909
2910 interface AudioHTMLAttributes<T> extends MediaHTMLAttributes<T> {}
2911
2912 interface AreaHTMLAttributes<T> extends HTMLAttributes<T> {
2913 alt?: string | undefined;
2914 coords?: string | undefined;
2915 download?: any;
2916 href?: string | undefined;
2917 hrefLang?: string | undefined;
2918 media?: string | undefined;
2919 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
2920 shape?: string | undefined;
2921 target?: string | undefined;
2922 }
2923
2924 interface BaseHTMLAttributes<T> extends HTMLAttributes<T> {
2925 href?: string | undefined;
2926 target?: string | undefined;
2927 }
2928
2929 interface BlockquoteHTMLAttributes<T> extends HTMLAttributes<T> {
2930 cite?: string | undefined;
2931 }
2932
2933 interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
2934 disabled?: boolean | undefined;
2935 form?: string | undefined;
2936 formAction?:
2937 | string
2938 | ((formData: FormData) => void | Promise<void>)
2939 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
2940 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
2941 ]
2942 | undefined;
2943 formEncType?: string | undefined;
2944 formMethod?: string | undefined;
2945 formNoValidate?: boolean | undefined;
2946 formTarget?: string | undefined;
2947 name?: string | undefined;
2948 type?: "submit" | "reset" | "button" | undefined;
2949 value?: string | readonly string[] | number | undefined;
2950 }
2951
2952 interface CanvasHTMLAttributes<T> extends HTMLAttributes<T> {
2953 height?: number | string | undefined;
2954 width?: number | string | undefined;
2955 }
2956
2957 interface ColHTMLAttributes<T> extends HTMLAttributes<T> {
2958 span?: number | undefined;
2959 width?: number | string | undefined;
2960 }
2961
2962 interface ColgroupHTMLAttributes<T> extends HTMLAttributes<T> {
2963 span?: number | undefined;
2964 }
2965
2966 interface DataHTMLAttributes<T> extends HTMLAttributes<T> {
2967 value?: string | readonly string[] | number | undefined;
2968 }
2969
2970 interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
2971 open?: boolean | undefined;
2972 name?: string | undefined;
2973 }
2974
2975 interface DelHTMLAttributes<T> extends HTMLAttributes<T> {
2976 cite?: string | undefined;
2977 dateTime?: string | undefined;
2978 }
2979
2980 interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
2981 onCancel?: ReactEventHandler<T> | undefined;
2982 onClose?: ReactEventHandler<T> | undefined;
2983 open?: boolean | undefined;
2984 }
2985
2986 interface EmbedHTMLAttributes<T> extends HTMLAttributes<T> {
2987 height?: number | string | undefined;
2988 src?: string | undefined;
2989 type?: string | undefined;
2990 width?: number | string | undefined;
2991 }
2992
2993 interface FieldsetHTMLAttributes<T> extends HTMLAttributes<T> {
2994 disabled?: boolean | undefined;
2995 form?: string | undefined;
2996 name?: string | undefined;
2997 }
2998
2999 interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
3000 acceptCharset?: string | undefined;
3001 action?:
3002 | string
3003 | undefined
3004 | ((formData: FormData) => void | Promise<void>)
3005 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3006 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3007 ];
3008 autoComplete?: string | undefined;
3009 encType?: string | undefined;
3010 method?: string | undefined;
3011 name?: string | undefined;
3012 noValidate?: boolean | undefined;
3013 target?: string | undefined;
3014 }
3015
3016 interface HtmlHTMLAttributes<T> extends HTMLAttributes<T> {
3017 manifest?: string | undefined;
3018 }
3019
3020 interface IframeHTMLAttributes<T> extends HTMLAttributes<T> {
3021 allow?: string | undefined;
3022 allowFullScreen?: boolean | undefined;
3023 allowTransparency?: boolean | undefined;
3024 /** @deprecated */
3025 frameBorder?: number | string | undefined;
3026 height?: number | string | undefined;
3027 loading?: "eager" | "lazy" | undefined;
3028 /** @deprecated */
3029 marginHeight?: number | undefined;
3030 /** @deprecated */
3031 marginWidth?: number | undefined;
3032 name?: string | undefined;
3033 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3034 sandbox?: string | undefined;
3035 /** @deprecated */
3036 scrolling?: string | undefined;
3037 seamless?: boolean | undefined;
3038 src?: string | undefined;
3039 srcDoc?: string | undefined;
3040 width?: number | string | undefined;
3041 }
3042
3043 interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
3044 alt?: string | undefined;
3045 crossOrigin?: CrossOrigin;
3046 decoding?: "async" | "auto" | "sync" | undefined;
3047 fetchPriority?: "high" | "low" | "auto";
3048 height?: number | string | undefined;
3049 loading?: "eager" | "lazy" | undefined;
3050 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3051 sizes?: string | undefined;
3052 src?: string | undefined;
3053 srcSet?: string | undefined;
3054 useMap?: string | undefined;
3055 width?: number | string | undefined;
3056 }
3057
3058 interface InsHTMLAttributes<T> extends HTMLAttributes<T> {
3059 cite?: string | undefined;
3060 dateTime?: string | undefined;
3061 }
3062
3063 type HTMLInputTypeAttribute =
3064 | "button"
3065 | "checkbox"
3066 | "color"
3067 | "date"
3068 | "datetime-local"
3069 | "email"
3070 | "file"
3071 | "hidden"
3072 | "image"
3073 | "month"
3074 | "number"
3075 | "password"
3076 | "radio"
3077 | "range"
3078 | "reset"
3079 | "search"
3080 | "submit"
3081 | "tel"
3082 | "text"
3083 | "time"
3084 | "url"
3085 | "week"
3086 | (string & {});
3087
3088 type AutoFillAddressKind = "billing" | "shipping";
3089 type AutoFillBase = "" | "off" | "on";
3090 type AutoFillContactField =
3091 | "email"
3092 | "tel"
3093 | "tel-area-code"
3094 | "tel-country-code"
3095 | "tel-extension"
3096 | "tel-local"
3097 | "tel-local-prefix"
3098 | "tel-local-suffix"
3099 | "tel-national";
3100 type AutoFillContactKind = "home" | "mobile" | "work";
3101 type AutoFillCredentialField = "webauthn";
3102 type AutoFillNormalField =
3103 | "additional-name"
3104 | "address-level1"
3105 | "address-level2"
3106 | "address-level3"
3107 | "address-level4"
3108 | "address-line1"
3109 | "address-line2"
3110 | "address-line3"
3111 | "bday-day"
3112 | "bday-month"
3113 | "bday-year"
3114 | "cc-csc"
3115 | "cc-exp"
3116 | "cc-exp-month"
3117 | "cc-exp-year"
3118 | "cc-family-name"
3119 | "cc-given-name"
3120 | "cc-name"
3121 | "cc-number"
3122 | "cc-type"
3123 | "country"
3124 | "country-name"
3125 | "current-password"
3126 | "family-name"
3127 | "given-name"
3128 | "honorific-prefix"
3129 | "honorific-suffix"
3130 | "name"
3131 | "new-password"
3132 | "one-time-code"
3133 | "organization"
3134 | "postal-code"
3135 | "street-address"
3136 | "transaction-amount"
3137 | "transaction-currency"
3138 | "username";
3139 type OptionalPrefixToken<T extends string> = `${T} ` | "";
3140 type OptionalPostfixToken<T extends string> = ` ${T}` | "";
3141 type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`;
3142 type AutoFillSection = `section-${string}`;
3143 type AutoFill =
3144 | AutoFillBase
3145 | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<
3146 AutoFillAddressKind
3147 >}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`;
3148 type HTMLInputAutoCompleteAttribute = AutoFill | (string & {});
3149
3150 interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
3151 accept?: string | undefined;
3152 alt?: string | undefined;
3153 autoComplete?: HTMLInputAutoCompleteAttribute | undefined;
3154 capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
3155 checked?: boolean | undefined;
3156 disabled?: boolean | undefined;
3157 form?: string | undefined;
3158 formAction?:
3159 | string
3160 | ((formData: FormData) => void | Promise<void>)
3161 | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[
3162 keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS
3163 ]
3164 | undefined;
3165 formEncType?: string | undefined;
3166 formMethod?: string | undefined;
3167 formNoValidate?: boolean | undefined;
3168 formTarget?: string | undefined;
3169 height?: number | string | undefined;
3170 list?: string | undefined;
3171 max?: number | string | undefined;
3172 maxLength?: number | undefined;
3173 min?: number | string | undefined;
3174 minLength?: number | undefined;
3175 multiple?: boolean | undefined;
3176 name?: string | undefined;
3177 pattern?: string | undefined;
3178 placeholder?: string | undefined;
3179 readOnly?: boolean | undefined;
3180 required?: boolean | undefined;
3181 size?: number | undefined;
3182 src?: string | undefined;
3183 step?: number | string | undefined;
3184 type?: HTMLInputTypeAttribute | undefined;
3185 value?: string | readonly string[] | number | undefined;
3186 width?: number | string | undefined;
3187
3188 onChange?: ChangeEventHandler<T> | undefined;
3189 }
3190
3191 interface KeygenHTMLAttributes<T> extends HTMLAttributes<T> {
3192 challenge?: string | undefined;
3193 disabled?: boolean | undefined;
3194 form?: string | undefined;
3195 keyType?: string | undefined;
3196 keyParams?: string | undefined;
3197 name?: string | undefined;
3198 }
3199
3200 interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
3201 form?: string | undefined;
3202 htmlFor?: string | undefined;
3203 }
3204
3205 interface LiHTMLAttributes<T> extends HTMLAttributes<T> {
3206 value?: string | readonly string[] | number | undefined;
3207 }
3208
3209 interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
3210 as?: string | undefined;
3211 crossOrigin?: CrossOrigin;
3212 fetchPriority?: "high" | "low" | "auto";
3213 href?: string | undefined;
3214 hrefLang?: string | undefined;
3215 integrity?: string | undefined;
3216 media?: string | undefined;
3217 imageSrcSet?: string | undefined;
3218 imageSizes?: string | undefined;
3219 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3220 sizes?: string | undefined;
3221 type?: string | undefined;
3222 charSet?: string | undefined;
3223
3224 // React props
3225 precedence?: string | undefined;
3226 }
3227
3228 interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
3229 name?: string | undefined;
3230 }
3231
3232 interface MenuHTMLAttributes<T> extends HTMLAttributes<T> {
3233 type?: string | undefined;
3234 }
3235
3236 interface MediaHTMLAttributes<T> extends HTMLAttributes<T> {
3237 autoPlay?: boolean | undefined;
3238 controls?: boolean | undefined;
3239 controlsList?: string | undefined;
3240 crossOrigin?: CrossOrigin;
3241 loop?: boolean | undefined;
3242 mediaGroup?: string | undefined;
3243 muted?: boolean | undefined;
3244 playsInline?: boolean | undefined;
3245 preload?: string | undefined;
3246 src?: string | undefined;
3247 }
3248
3249 interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
3250 charSet?: string | undefined;
3251 content?: string | undefined;
3252 httpEquiv?: string | undefined;
3253 media?: string | undefined;
3254 name?: string | undefined;
3255 }
3256
3257 interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
3258 form?: string | undefined;
3259 high?: number | undefined;
3260 low?: number | undefined;
3261 max?: number | string | undefined;
3262 min?: number | string | undefined;
3263 optimum?: number | undefined;
3264 value?: string | readonly string[] | number | undefined;
3265 }
3266
3267 interface QuoteHTMLAttributes<T> extends HTMLAttributes<T> {
3268 cite?: string | undefined;
3269 }
3270
3271 interface ObjectHTMLAttributes<T> extends HTMLAttributes<T> {
3272 classID?: string | undefined;
3273 data?: string | undefined;
3274 form?: string | undefined;
3275 height?: number | string | undefined;
3276 name?: string | undefined;
3277 type?: string | undefined;
3278 useMap?: string | undefined;
3279 width?: number | string | undefined;
3280 wmode?: string | undefined;
3281 }
3282
3283 interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
3284 reversed?: boolean | undefined;
3285 start?: number | undefined;
3286 type?: "1" | "a" | "A" | "i" | "I" | undefined;
3287 }
3288
3289 interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
3290 disabled?: boolean | undefined;
3291 label?: string | undefined;
3292 }
3293
3294 interface OptionHTMLAttributes<T> extends HTMLAttributes<T> {
3295 disabled?: boolean | undefined;
3296 label?: string | undefined;
3297 selected?: boolean | undefined;
3298 value?: string | readonly string[] | number | undefined;
3299 }
3300
3301 interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
3302 form?: string | undefined;
3303 htmlFor?: string | undefined;
3304 name?: string | undefined;
3305 }
3306
3307 interface ParamHTMLAttributes<T> extends HTMLAttributes<T> {
3308 name?: string | undefined;
3309 value?: string | readonly string[] | number | undefined;
3310 }
3311
3312 interface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {
3313 max?: number | string | undefined;
3314 value?: string | readonly string[] | number | undefined;
3315 }
3316
3317 interface SlotHTMLAttributes<T> extends HTMLAttributes<T> {
3318 name?: string | undefined;
3319 }
3320
3321 interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
3322 async?: boolean | undefined;
3323 /** @deprecated */
3324 charSet?: string | undefined;
3325 crossOrigin?: CrossOrigin;
3326 defer?: boolean | undefined;
3327 integrity?: string | undefined;
3328 noModule?: boolean | undefined;
3329 referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
3330 src?: string | undefined;
3331 type?: string | undefined;
3332 }
3333
3334 interface SelectHTMLAttributes<T> extends HTMLAttributes<T> {
3335 autoComplete?: string | undefined;
3336 disabled?: boolean | undefined;
3337 form?: string | undefined;
3338 multiple?: boolean | undefined;
3339 name?: string | undefined;
3340 required?: boolean | undefined;
3341 size?: number | undefined;
3342 value?: string | readonly string[] | number | undefined;
3343 onChange?: ChangeEventHandler<T> | undefined;
3344 }
3345
3346 interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
3347 height?: number | string | undefined;
3348 media?: string | undefined;
3349 sizes?: string | undefined;
3350 src?: string | undefined;
3351 srcSet?: string | undefined;
3352 type?: string | undefined;
3353 width?: number | string | undefined;
3354 }
3355
3356 interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
3357 media?: string | undefined;
3358 scoped?: boolean | undefined;
3359 type?: string | undefined;
3360
3361 // React props
3362 href?: string | undefined;
3363 precedence?: string | undefined;
3364 }
3365
3366 interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
3367 align?: "left" | "center" | "right" | undefined;
3368 bgcolor?: string | undefined;
3369 border?: number | undefined;
3370 cellPadding?: number | string | undefined;
3371 cellSpacing?: number | string | undefined;
3372 frame?: boolean | undefined;
3373 rules?: "none" | "groups" | "rows" | "columns" | "all" | undefined;
3374 summary?: string | undefined;
3375 width?: number | string | undefined;
3376 }
3377
3378 interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
3379 autoComplete?: string | undefined;
3380 cols?: number | undefined;
3381 dirName?: string | undefined;
3382 disabled?: boolean | undefined;
3383 form?: string | undefined;
3384 maxLength?: number | undefined;
3385 minLength?: number | undefined;
3386 name?: string | undefined;
3387 placeholder?: string | undefined;
3388 readOnly?: boolean | undefined;
3389 required?: boolean | undefined;
3390 rows?: number | undefined;
3391 value?: string | readonly string[] | number | undefined;
3392 wrap?: string | undefined;
3393
3394 onChange?: ChangeEventHandler<T> | undefined;
3395 }
3396
3397 interface TdHTMLAttributes<T> extends HTMLAttributes<T> {
3398 align?: "left" | "center" | "right" | "justify" | "char" | undefined;
3399 colSpan?: number | undefined;
3400 headers?: string | undefined;
3401 rowSpan?: number | undefined;
3402 scope?: string | undefined;
3403 abbr?: string | undefined;
3404 height?: number | string | undefined;
3405 width?: number | string | undefined;
3406 valign?: "top" | "middle" | "bottom" | "baseline" | undefined;
3407 }
3408
3409 interface ThHTMLAttributes<T> extends HTMLAttributes<T> {
3410 align?: "left" | "center" | "right" | "justify" | "char" | undefined;
3411 colSpan?: number | undefined;
3412 headers?: string | undefined;
3413 rowSpan?: number | undefined;
3414 scope?: string | undefined;
3415 abbr?: string | undefined;
3416 }
3417
3418 interface TimeHTMLAttributes<T> extends HTMLAttributes<T> {
3419 dateTime?: string | undefined;
3420 }
3421
3422 interface TrackHTMLAttributes<T> extends HTMLAttributes<T> {
3423 default?: boolean | undefined;
3424 kind?: string | undefined;
3425 label?: string | undefined;
3426 src?: string | undefined;
3427 srcLang?: string | undefined;
3428 }
3429
3430 interface VideoHTMLAttributes<T> extends MediaHTMLAttributes<T> {
3431 height?: number | string | undefined;
3432 playsInline?: boolean | undefined;
3433 poster?: string | undefined;
3434 width?: number | string | undefined;
3435 disablePictureInPicture?: boolean | undefined;
3436 disableRemotePlayback?: boolean | undefined;
3437 }
3438
3439 // this list is "complete" in that it contains every SVG attribute
3440 // that React supports, but the types can be improved.
3441 // Full list here: https://facebook.github.io/react/docs/dom-elements.html
3442 //
3443 // The three broad type categories are (in order of restrictiveness):
3444 // - "number | string"
3445 // - "string"
3446 // - union of string literals
3447 interface SVGAttributes<T> extends AriaAttributes, DOMAttributes<T> {
3448 // React-specific Attributes
3449 suppressHydrationWarning?: boolean | undefined;
3450
3451 // Attributes which also defined in HTMLAttributes
3452 // See comment in SVGDOMPropertyConfig.js
3453 className?: string | undefined;
3454 color?: string | undefined;
3455 height?: number | string | undefined;
3456 id?: string | undefined;
3457 lang?: string | undefined;
3458 max?: number | string | undefined;
3459 media?: string | undefined;
3460 method?: string | undefined;
3461 min?: number | string | undefined;
3462 name?: string | undefined;
3463 style?: CSSProperties | undefined;
3464 target?: string | undefined;
3465 type?: string | undefined;
3466 width?: number | string | undefined;
3467
3468 // Other HTML properties supported by SVG elements in browsers
3469 role?: AriaRole | undefined;
3470 tabIndex?: number | undefined;
3471 crossOrigin?: CrossOrigin;
3472
3473 // SVG Specific attributes
3474 accentHeight?: number | string | undefined;
3475 accumulate?: "none" | "sum" | undefined;
3476 additive?: "replace" | "sum" | undefined;
3477 alignmentBaseline?:
3478 | "auto"
3479 | "baseline"
3480 | "before-edge"
3481 | "text-before-edge"
3482 | "middle"
3483 | "central"
3484 | "after-edge"
3485 | "text-after-edge"
3486 | "ideographic"
3487 | "alphabetic"
3488 | "hanging"
3489 | "mathematical"
3490 | "inherit"
3491 | undefined;
3492 allowReorder?: "no" | "yes" | undefined;
3493 alphabetic?: number | string | undefined;
3494 amplitude?: number | string | undefined;
3495 arabicForm?: "initial" | "medial" | "terminal" | "isolated" | undefined;
3496 ascent?: number | string | undefined;
3497 attributeName?: string | undefined;
3498 attributeType?: string | undefined;
3499 autoReverse?: Booleanish | undefined;
3500 azimuth?: number | string | undefined;
3501 baseFrequency?: number | string | undefined;
3502 baselineShift?: number | string | undefined;
3503 baseProfile?: number | string | undefined;
3504 bbox?: number | string | undefined;
3505 begin?: number | string | undefined;
3506 bias?: number | string | undefined;
3507 by?: number | string | undefined;
3508 calcMode?: number | string | undefined;
3509 capHeight?: number | string | undefined;
3510 clip?: number | string | undefined;
3511 clipPath?: string | undefined;
3512 clipPathUnits?: number | string | undefined;
3513 clipRule?: number | string | undefined;
3514 colorInterpolation?: number | string | undefined;
3515 colorInterpolationFilters?: "auto" | "sRGB" | "linearRGB" | "inherit" | undefined;
3516 colorProfile?: number | string | undefined;
3517 colorRendering?: number | string | undefined;
3518 contentScriptType?: number | string | undefined;
3519 contentStyleType?: number | string | undefined;
3520 cursor?: number | string | undefined;
3521 cx?: number | string | undefined;
3522 cy?: number | string | undefined;
3523 d?: string | undefined;
3524 decelerate?: number | string | undefined;
3525 descent?: number | string | undefined;
3526 diffuseConstant?: number | string | undefined;
3527 direction?: number | string | undefined;
3528 display?: number | string | undefined;
3529 divisor?: number | string | undefined;
3530 dominantBaseline?: number | string | undefined;
3531 dur?: number | string | undefined;
3532 dx?: number | string | undefined;
3533 dy?: number | string | undefined;
3534 edgeMode?: number | string | undefined;
3535 elevation?: number | string | undefined;
3536 enableBackground?: number | string | undefined;
3537 end?: number | string | undefined;
3538 exponent?: number | string | undefined;
3539 externalResourcesRequired?: Booleanish | undefined;
3540 fill?: string | undefined;
3541 fillOpacity?: number | string | undefined;
3542 fillRule?: "nonzero" | "evenodd" | "inherit" | undefined;
3543 filter?: string | undefined;
3544 filterRes?: number | string | undefined;
3545 filterUnits?: number | string | undefined;
3546 floodColor?: number | string | undefined;
3547 floodOpacity?: number | string | undefined;
3548 focusable?: Booleanish | "auto" | undefined;
3549 fontFamily?: string | undefined;
3550 fontSize?: number | string | undefined;
3551 fontSizeAdjust?: number | string | undefined;
3552 fontStretch?: number | string | undefined;
3553 fontStyle?: number | string | undefined;
3554 fontVariant?: number | string | undefined;
3555 fontWeight?: number | string | undefined;
3556 format?: number | string | undefined;
3557 fr?: number | string | undefined;
3558 from?: number | string | undefined;
3559 fx?: number | string | undefined;
3560 fy?: number | string | undefined;
3561 g1?: number | string | undefined;
3562 g2?: number | string | undefined;
3563 glyphName?: number | string | undefined;
3564 glyphOrientationHorizontal?: number | string | undefined;
3565 glyphOrientationVertical?: number | string | undefined;
3566 glyphRef?: number | string | undefined;
3567 gradientTransform?: string | undefined;
3568 gradientUnits?: string | undefined;
3569 hanging?: number | string | undefined;
3570 horizAdvX?: number | string | undefined;
3571 horizOriginX?: number | string | undefined;
3572 href?: string | undefined;
3573 ideographic?: number | string | undefined;
3574 imageRendering?: number | string | undefined;
3575 in2?: number | string | undefined;
3576 in?: string | undefined;
3577 intercept?: number | string | undefined;
3578 k1?: number | string | undefined;
3579 k2?: number | string | undefined;
3580 k3?: number | string | undefined;
3581 k4?: number | string | undefined;
3582 k?: number | string | undefined;
3583 kernelMatrix?: number | string | undefined;
3584 kernelUnitLength?: number | string | undefined;
3585 kerning?: number | string | undefined;
3586 keyPoints?: number | string | undefined;
3587 keySplines?: number | string | undefined;
3588 keyTimes?: number | string | undefined;
3589 lengthAdjust?: number | string | undefined;
3590 letterSpacing?: number | string | undefined;
3591 lightingColor?: number | string | undefined;
3592 limitingConeAngle?: number | string | undefined;
3593 local?: number | string | undefined;
3594 markerEnd?: string | undefined;
3595 markerHeight?: number | string | undefined;
3596 markerMid?: string | undefined;
3597 markerStart?: string | undefined;
3598 markerUnits?: number | string | undefined;
3599 markerWidth?: number | string | undefined;
3600 mask?: string | undefined;
3601 maskContentUnits?: number | string | undefined;
3602 maskUnits?: number | string | undefined;
3603 mathematical?: number | string | undefined;
3604 mode?: number | string | undefined;
3605 numOctaves?: number | string | undefined;
3606 offset?: number | string | undefined;
3607 opacity?: number | string | undefined;
3608 operator?: number | string | undefined;
3609 order?: number | string | undefined;
3610 orient?: number | string | undefined;
3611 orientation?: number | string | undefined;
3612 origin?: number | string | undefined;
3613 overflow?: number | string | undefined;
3614 overlinePosition?: number | string | undefined;
3615 overlineThickness?: number | string | undefined;
3616 paintOrder?: number | string | undefined;
3617 panose1?: number | string | undefined;
3618 path?: string | undefined;
3619 pathLength?: number | string | undefined;
3620 patternContentUnits?: string | undefined;
3621 patternTransform?: number | string | undefined;
3622 patternUnits?: string | undefined;
3623 pointerEvents?: number | string | undefined;
3624 points?: string | undefined;
3625 pointsAtX?: number | string | undefined;
3626 pointsAtY?: number | string | undefined;
3627 pointsAtZ?: number | string | undefined;
3628 preserveAlpha?: Booleanish | undefined;
3629 preserveAspectRatio?: string | undefined;
3630 primitiveUnits?: number | string | undefined;
3631 r?: number | string | undefined;
3632 radius?: number | string | undefined;
3633 refX?: number | string | undefined;
3634 refY?: number | string | undefined;
3635 renderingIntent?: number | string | undefined;
3636 repeatCount?: number | string | undefined;
3637 repeatDur?: number | string | undefined;
3638 requiredExtensions?: number | string | undefined;
3639 requiredFeatures?: number | string | undefined;
3640 restart?: number | string | undefined;
3641 result?: string | undefined;
3642 rotate?: number | string | undefined;
3643 rx?: number | string | undefined;
3644 ry?: number | string | undefined;
3645 scale?: number | string | undefined;
3646 seed?: number | string | undefined;
3647 shapeRendering?: number | string | undefined;
3648 slope?: number | string | undefined;
3649 spacing?: number | string | undefined;
3650 specularConstant?: number | string | undefined;
3651 specularExponent?: number | string | undefined;
3652 speed?: number | string | undefined;
3653 spreadMethod?: string | undefined;
3654 startOffset?: number | string | undefined;
3655 stdDeviation?: number | string | undefined;
3656 stemh?: number | string | undefined;
3657 stemv?: number | string | undefined;
3658 stitchTiles?: number | string | undefined;
3659 stopColor?: string | undefined;
3660 stopOpacity?: number | string | undefined;
3661 strikethroughPosition?: number | string | undefined;
3662 strikethroughThickness?: number | string | undefined;
3663 string?: number | string | undefined;
3664 stroke?: string | undefined;
3665 strokeDasharray?: string | number | undefined;
3666 strokeDashoffset?: string | number | undefined;
3667 strokeLinecap?: "butt" | "round" | "square" | "inherit" | undefined;
3668 strokeLinejoin?: "miter" | "round" | "bevel" | "inherit" | undefined;
3669 strokeMiterlimit?: number | string | undefined;
3670 strokeOpacity?: number | string | undefined;
3671 strokeWidth?: number | string | undefined;
3672 surfaceScale?: number | string | undefined;
3673 systemLanguage?: number | string | undefined;
3674 tableValues?: number | string | undefined;
3675 targetX?: number | string | undefined;
3676 targetY?: number | string | undefined;
3677 textAnchor?: string | undefined;
3678 textDecoration?: number | string | undefined;
3679 textLength?: number | string | undefined;
3680 textRendering?: number | string | undefined;
3681 to?: number | string | undefined;
3682 transform?: string | undefined;
3683 u1?: number | string | undefined;
3684 u2?: number | string | undefined;
3685 underlinePosition?: number | string | undefined;
3686 underlineThickness?: number | string | undefined;
3687 unicode?: number | string | undefined;
3688 unicodeBidi?: number | string | undefined;
3689 unicodeRange?: number | string | undefined;
3690 unitsPerEm?: number | string | undefined;
3691 vAlphabetic?: number | string | undefined;
3692 values?: string | undefined;
3693 vectorEffect?: number | string | undefined;
3694 version?: string | undefined;
3695 vertAdvY?: number | string | undefined;
3696 vertOriginX?: number | string | undefined;
3697 vertOriginY?: number | string | undefined;
3698 vHanging?: number | string | undefined;
3699 vIdeographic?: number | string | undefined;
3700 viewBox?: string | undefined;
3701 viewTarget?: number | string | undefined;
3702 visibility?: number | string | undefined;
3703 vMathematical?: number | string | undefined;
3704 widths?: number | string | undefined;
3705 wordSpacing?: number | string | undefined;
3706 writingMode?: number | string | undefined;
3707 x1?: number | string | undefined;
3708 x2?: number | string | undefined;
3709 x?: number | string | undefined;
3710 xChannelSelector?: string | undefined;
3711 xHeight?: number | string | undefined;
3712 xlinkActuate?: string | undefined;
3713 xlinkArcrole?: string | undefined;
3714 xlinkHref?: string | undefined;
3715 xlinkRole?: string | undefined;
3716 xlinkShow?: string | undefined;
3717 xlinkTitle?: string | undefined;
3718 xlinkType?: string | undefined;
3719 xmlBase?: string | undefined;
3720 xmlLang?: string | undefined;
3721 xmlns?: string | undefined;
3722 xmlnsXlink?: string | undefined;
3723 xmlSpace?: string | undefined;
3724 y1?: number | string | undefined;
3725 y2?: number | string | undefined;
3726 y?: number | string | undefined;
3727 yChannelSelector?: string | undefined;
3728 z?: number | string | undefined;
3729 zoomAndPan?: string | undefined;
3730 }
3731
3732 interface WebViewHTMLAttributes<T> extends HTMLAttributes<T> {
3733 allowFullScreen?: boolean | undefined;
3734 allowpopups?: boolean | undefined;
3735 autosize?: boolean | undefined;
3736 blinkfeatures?: string | undefined;
3737 disableblinkfeatures?: string | undefined;
3738 disableguestresize?: boolean | undefined;
3739 disablewebsecurity?: boolean | undefined;
3740 guestinstance?: string | undefined;
3741 httpreferrer?: string | undefined;
3742 nodeintegration?: boolean | undefined;
3743 partition?: string | undefined;
3744 plugins?: boolean | undefined;
3745 preload?: string | undefined;
3746 src?: string | undefined;
3747 useragent?: string | undefined;
3748 webpreferences?: string | undefined;
3749 }
3750
3751 // TODO: Move to react-dom
3752 type HTMLElementType =
3753 | "a"
3754 | "abbr"
3755 | "address"
3756 | "area"
3757 | "article"
3758 | "aside"
3759 | "audio"
3760 | "b"
3761 | "base"
3762 | "bdi"
3763 | "bdo"
3764 | "big"
3765 | "blockquote"
3766 | "body"
3767 | "br"
3768 | "button"
3769 | "canvas"
3770 | "caption"
3771 | "center"
3772 | "cite"
3773 | "code"
3774 | "col"
3775 | "colgroup"
3776 | "data"
3777 | "datalist"
3778 | "dd"
3779 | "del"
3780 | "details"
3781 | "dfn"
3782 | "dialog"
3783 | "div"
3784 | "dl"
3785 | "dt"
3786 | "em"
3787 | "embed"
3788 | "fieldset"
3789 | "figcaption"
3790 | "figure"
3791 | "footer"
3792 | "form"
3793 | "h1"
3794 | "h2"
3795 | "h3"
3796 | "h4"
3797 | "h5"
3798 | "h6"
3799 | "head"
3800 | "header"
3801 | "hgroup"
3802 | "hr"
3803 | "html"
3804 | "i"
3805 | "iframe"
3806 | "img"
3807 | "input"
3808 | "ins"
3809 | "kbd"
3810 | "keygen"
3811 | "label"
3812 | "legend"
3813 | "li"
3814 | "link"
3815 | "main"
3816 | "map"
3817 | "mark"
3818 | "menu"
3819 | "menuitem"
3820 | "meta"
3821 | "meter"
3822 | "nav"
3823 | "noscript"
3824 | "object"
3825 | "ol"
3826 | "optgroup"
3827 | "option"
3828 | "output"
3829 | "p"
3830 | "param"
3831 | "picture"
3832 | "pre"
3833 | "progress"
3834 | "q"
3835 | "rp"
3836 | "rt"
3837 | "ruby"
3838 | "s"
3839 | "samp"
3840 | "search"
3841 | "slot"
3842 | "script"
3843 | "section"
3844 | "select"
3845 | "small"
3846 | "source"
3847 | "span"
3848 | "strong"
3849 | "style"
3850 | "sub"
3851 | "summary"
3852 | "sup"
3853 | "table"
3854 | "template"
3855 | "tbody"
3856 | "td"
3857 | "textarea"
3858 | "tfoot"
3859 | "th"
3860 | "thead"
3861 | "time"
3862 | "title"
3863 | "tr"
3864 | "track"
3865 | "u"
3866 | "ul"
3867 | "var"
3868 | "video"
3869 | "wbr"
3870 | "webview";
3871
3872 // TODO: Move to react-dom
3873 type SVGElementType =
3874 | "animate"
3875 | "circle"
3876 | "clipPath"
3877 | "defs"
3878 | "desc"
3879 | "ellipse"
3880 | "feBlend"
3881 | "feColorMatrix"
3882 | "feComponentTransfer"
3883 | "feComposite"
3884 | "feConvolveMatrix"
3885 | "feDiffuseLighting"
3886 | "feDisplacementMap"
3887 | "feDistantLight"
3888 | "feDropShadow"
3889 | "feFlood"
3890 | "feFuncA"
3891 | "feFuncB"
3892 | "feFuncG"
3893 | "feFuncR"
3894 | "feGaussianBlur"
3895 | "feImage"
3896 | "feMerge"
3897 | "feMergeNode"
3898 | "feMorphology"
3899 | "feOffset"
3900 | "fePointLight"
3901 | "feSpecularLighting"
3902 | "feSpotLight"
3903 | "feTile"
3904 | "feTurbulence"
3905 | "filter"
3906 | "foreignObject"
3907 | "g"
3908 | "image"
3909 | "line"
3910 | "linearGradient"
3911 | "marker"
3912 | "mask"
3913 | "metadata"
3914 | "path"
3915 | "pattern"
3916 | "polygon"
3917 | "polyline"
3918 | "radialGradient"
3919 | "rect"
3920 | "stop"
3921 | "svg"
3922 | "switch"
3923 | "symbol"
3924 | "text"
3925 | "textPath"
3926 | "tspan"
3927 | "use"
3928 | "view";
3929
3930 //
3931 // Browser Interfaces
3932 // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts
3933 // ----------------------------------------------------------------------
3934
3935 interface AbstractView {
3936 styleMedia: StyleMedia;
3937 document: Document;
3938 }
3939
3940 interface Touch {
3941 identifier: number;
3942 target: EventTarget;
3943 screenX: number;
3944 screenY: number;
3945 clientX: number;
3946 clientY: number;
3947 pageX: number;
3948 pageY: number;
3949 }
3950
3951 interface TouchList {
3952 [index: number]: Touch;
3953 length: number;
3954 item(index: number): Touch;
3955 identifiedTouch(identifier: number): Touch;
3956 }
3957
3958 //
3959 // Error Interfaces
3960 // ----------------------------------------------------------------------
3961 interface ErrorInfo {
3962 /**
3963 * Captures which component contained the exception, and its ancestors.
3964 */
3965 componentStack?: string | null;
3966 digest?: string | null;
3967 }
3968
3969 // Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
3970 namespace JSX {
3971 // We don't just alias React.ElementType because React.ElementType
3972 // historically does more than we need it to.
3973 // E.g. it also contains .propTypes and so TS also verifies the declared
3974 // props type does match the declared .propTypes.
3975 // But if libraries declared their .propTypes but not props type,
3976 // or they mismatch, you won't be able to use the class component
3977 // as a JSX.ElementType.
3978 // We could fix this everywhere but we're ultimately not interested in
3979 // .propTypes assignability so we might as well drop it entirely here to
3980 // reduce the work of the type-checker.
3981 // TODO: Check impact of making React.ElementType<P = any> = React.JSXElementConstructor<P>
3982 type ElementType = string | React.JSXElementConstructor<any>;
3983 interface Element extends React.ReactElement<any, any> {}
3984 interface ElementClass extends React.Component<any> {
3985 render(): React.ReactNode;
3986 }
3987 interface ElementAttributesProperty {
3988 props: {};
3989 }
3990 interface ElementChildrenAttribute {
3991 children: {};
3992 }
3993
3994 // We can't recurse forever because `type` can't be self-referential;
3995 // let's assume it's reasonable to do a single React.lazy() around a single React.memo() / vice-versa
3996 type LibraryManagedAttributes<C, P> = C extends
3997 React.MemoExoticComponent<infer T> | React.LazyExoticComponent<infer T>
3998 ? T extends React.MemoExoticComponent<infer U> | React.LazyExoticComponent<infer U>
3999 ? ReactManagedAttributes<U, P>
4000 : ReactManagedAttributes<T, P>
4001 : ReactManagedAttributes<C, P>;
4002
4003 interface IntrinsicAttributes extends React.Attributes {}
4004 interface IntrinsicClassAttributes<T> extends React.ClassAttributes<T> {}
4005
4006 interface IntrinsicElements {
4007 // HTML
4008 a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
4009 abbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4010 address: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4011 area: React.DetailedHTMLProps<React.AreaHTMLAttributes<HTMLAreaElement>, HTMLAreaElement>;
4012 article: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4013 aside: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4014 audio: React.DetailedHTMLProps<React.AudioHTMLAttributes<HTMLAudioElement>, HTMLAudioElement>;
4015 b: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4016 base: React.DetailedHTMLProps<React.BaseHTMLAttributes<HTMLBaseElement>, HTMLBaseElement>;
4017 bdi: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4018 bdo: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4019 big: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4020 blockquote: React.DetailedHTMLProps<React.BlockquoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4021 body: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>;
4022 br: React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
4023 button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
4024 canvas: React.DetailedHTMLProps<React.CanvasHTMLAttributes<HTMLCanvasElement>, HTMLCanvasElement>;
4025 caption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4026 center: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4027 cite: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4028 code: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4029 col: React.DetailedHTMLProps<React.ColHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
4030 colgroup: React.DetailedHTMLProps<React.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>;
4031 data: React.DetailedHTMLProps<React.DataHTMLAttributes<HTMLDataElement>, HTMLDataElement>;
4032 datalist: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDataListElement>, HTMLDataListElement>;
4033 dd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4034 del: React.DetailedHTMLProps<React.DelHTMLAttributes<HTMLModElement>, HTMLModElement>;
4035 details: React.DetailedHTMLProps<React.DetailsHTMLAttributes<HTMLDetailsElement>, HTMLDetailsElement>;
4036 dfn: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4037 dialog: React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>;
4038 div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
4039 dl: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>;
4040 dt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4041 em: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4042 embed: React.DetailedHTMLProps<React.EmbedHTMLAttributes<HTMLEmbedElement>, HTMLEmbedElement>;
4043 fieldset: React.DetailedHTMLProps<React.FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>;
4044 figcaption: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4045 figure: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4046 footer: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4047 form: React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
4048 h1: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4049 h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4050 h3: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4051 h4: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4052 h5: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4053 h6: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
4054 head: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>;
4055 header: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4056 hgroup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4057 hr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHRElement>, HTMLHRElement>;
4058 html: React.DetailedHTMLProps<React.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>;
4059 i: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4060 iframe: React.DetailedHTMLProps<React.IframeHTMLAttributes<HTMLIFrameElement>, HTMLIFrameElement>;
4061 img: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
4062 input: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4063 ins: React.DetailedHTMLProps<React.InsHTMLAttributes<HTMLModElement>, HTMLModElement>;
4064 kbd: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4065 keygen: React.DetailedHTMLProps<React.KeygenHTMLAttributes<HTMLElement>, HTMLElement>;
4066 label: React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
4067 legend: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>;
4068 li: React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>;
4069 link: React.DetailedHTMLProps<React.LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>;
4070 main: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4071 map: React.DetailedHTMLProps<React.MapHTMLAttributes<HTMLMapElement>, HTMLMapElement>;
4072 mark: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4073 menu: React.DetailedHTMLProps<React.MenuHTMLAttributes<HTMLElement>, HTMLElement>;
4074 menuitem: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4075 meta: React.DetailedHTMLProps<React.MetaHTMLAttributes<HTMLMetaElement>, HTMLMetaElement>;
4076 meter: React.DetailedHTMLProps<React.MeterHTMLAttributes<HTMLMeterElement>, HTMLMeterElement>;
4077 nav: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4078 noindex: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4079 noscript: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4080 object: React.DetailedHTMLProps<React.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>;
4081 ol: React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>;
4082 optgroup: React.DetailedHTMLProps<React.OptgroupHTMLAttributes<HTMLOptGroupElement>, HTMLOptGroupElement>;
4083 option: React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
4084 output: React.DetailedHTMLProps<React.OutputHTMLAttributes<HTMLOutputElement>, HTMLOutputElement>;
4085 p: React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
4086 param: React.DetailedHTMLProps<React.ParamHTMLAttributes<HTMLParamElement>, HTMLParamElement>;
4087 picture: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4088 pre: React.DetailedHTMLProps<React.HTMLAttributes<HTMLPreElement>, HTMLPreElement>;
4089 progress: React.DetailedHTMLProps<React.ProgressHTMLAttributes<HTMLProgressElement>, HTMLProgressElement>;
4090 q: React.DetailedHTMLProps<React.QuoteHTMLAttributes<HTMLQuoteElement>, HTMLQuoteElement>;
4091 rp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4092 rt: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4093 ruby: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4094 s: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4095 samp: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4096 search: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4097 slot: React.DetailedHTMLProps<React.SlotHTMLAttributes<HTMLSlotElement>, HTMLSlotElement>;
4098 script: React.DetailedHTMLProps<React.ScriptHTMLAttributes<HTMLScriptElement>, HTMLScriptElement>;
4099 section: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4100 select: React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
4101 small: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4102 source: React.DetailedHTMLProps<React.SourceHTMLAttributes<HTMLSourceElement>, HTMLSourceElement>;
4103 span: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
4104 strong: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4105 style: React.DetailedHTMLProps<React.StyleHTMLAttributes<HTMLStyleElement>, HTMLStyleElement>;
4106 sub: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4107 summary: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4108 sup: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4109 table: React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
4110 template: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTemplateElement>, HTMLTemplateElement>;
4111 tbody: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4112 td: React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
4113 textarea: React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
4114 tfoot: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4115 th: React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
4116 thead: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>;
4117 time: React.DetailedHTMLProps<React.TimeHTMLAttributes<HTMLTimeElement>, HTMLTimeElement>;
4118 title: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTitleElement>, HTMLTitleElement>;
4119 tr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
4120 track: React.DetailedHTMLProps<React.TrackHTMLAttributes<HTMLTrackElement>, HTMLTrackElement>;
4121 u: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4122 ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
4123 "var": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4124 video: React.DetailedHTMLProps<React.VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>;
4125 wbr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
4126 webview: React.DetailedHTMLProps<React.WebViewHTMLAttributes<HTMLWebViewElement>, HTMLWebViewElement>;
4127
4128 // SVG
4129 svg: React.SVGProps<SVGSVGElement>;
4130
4131 animate: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateElement but is not in TypeScript's lib.dom.d.ts for now.
4132 animateMotion: React.SVGProps<SVGElement>;
4133 animateTransform: React.SVGProps<SVGElement>; // TODO: It is SVGAnimateTransformElement but is not in TypeScript's lib.dom.d.ts for now.
4134 circle: React.SVGProps<SVGCircleElement>;
4135 clipPath: React.SVGProps<SVGClipPathElement>;
4136 defs: React.SVGProps<SVGDefsElement>;
4137 desc: React.SVGProps<SVGDescElement>;
4138 ellipse: React.SVGProps<SVGEllipseElement>;
4139 feBlend: React.SVGProps<SVGFEBlendElement>;
4140 feColorMatrix: React.SVGProps<SVGFEColorMatrixElement>;
4141 feComponentTransfer: React.SVGProps<SVGFEComponentTransferElement>;
4142 feComposite: React.SVGProps<SVGFECompositeElement>;
4143 feConvolveMatrix: React.SVGProps<SVGFEConvolveMatrixElement>;
4144 feDiffuseLighting: React.SVGProps<SVGFEDiffuseLightingElement>;
4145 feDisplacementMap: React.SVGProps<SVGFEDisplacementMapElement>;
4146 feDistantLight: React.SVGProps<SVGFEDistantLightElement>;
4147 feDropShadow: React.SVGProps<SVGFEDropShadowElement>;
4148 feFlood: React.SVGProps<SVGFEFloodElement>;
4149 feFuncA: React.SVGProps<SVGFEFuncAElement>;
4150 feFuncB: React.SVGProps<SVGFEFuncBElement>;
4151 feFuncG: React.SVGProps<SVGFEFuncGElement>;
4152 feFuncR: React.SVGProps<SVGFEFuncRElement>;
4153 feGaussianBlur: React.SVGProps<SVGFEGaussianBlurElement>;
4154 feImage: React.SVGProps<SVGFEImageElement>;
4155 feMerge: React.SVGProps<SVGFEMergeElement>;
4156 feMergeNode: React.SVGProps<SVGFEMergeNodeElement>;
4157 feMorphology: React.SVGProps<SVGFEMorphologyElement>;
4158 feOffset: React.SVGProps<SVGFEOffsetElement>;
4159 fePointLight: React.SVGProps<SVGFEPointLightElement>;
4160 feSpecularLighting: React.SVGProps<SVGFESpecularLightingElement>;
4161 feSpotLight: React.SVGProps<SVGFESpotLightElement>;
4162 feTile: React.SVGProps<SVGFETileElement>;
4163 feTurbulence: React.SVGProps<SVGFETurbulenceElement>;
4164 filter: React.SVGProps<SVGFilterElement>;
4165 foreignObject: React.SVGProps<SVGForeignObjectElement>;
4166 g: React.SVGProps<SVGGElement>;
4167 image: React.SVGProps<SVGImageElement>;
4168 line: React.SVGLineElementAttributes<SVGLineElement>;
4169 linearGradient: React.SVGProps<SVGLinearGradientElement>;
4170 marker: React.SVGProps<SVGMarkerElement>;
4171 mask: React.SVGProps<SVGMaskElement>;
4172 metadata: React.SVGProps<SVGMetadataElement>;
4173 mpath: React.SVGProps<SVGElement>;
4174 path: React.SVGProps<SVGPathElement>;
4175 pattern: React.SVGProps<SVGPatternElement>;
4176 polygon: React.SVGProps<SVGPolygonElement>;
4177 polyline: React.SVGProps<SVGPolylineElement>;
4178 radialGradient: React.SVGProps<SVGRadialGradientElement>;
4179 rect: React.SVGProps<SVGRectElement>;
4180 set: React.SVGProps<SVGSetElement>;
4181 stop: React.SVGProps<SVGStopElement>;
4182 switch: React.SVGProps<SVGSwitchElement>;
4183 symbol: React.SVGProps<SVGSymbolElement>;
4184 text: React.SVGTextElementAttributes<SVGTextElement>;
4185 textPath: React.SVGProps<SVGTextPathElement>;
4186 tspan: React.SVGProps<SVGTSpanElement>;
4187 use: React.SVGProps<SVGUseElement>;
4188 view: React.SVGProps<SVGViewElement>;
4189 }
4190 }
4191}
4192
4193type InexactPartial<T> = { [K in keyof T]?: T[K] | undefined };
4194
4195// Any prop that has a default prop becomes optional, but its type is unchanged
4196// Undeclared default props are augmented into the resulting allowable attributes
4197// If declared props have indexed properties, ignore default props entirely as keyof gets widened
4198// Wrap in an outer-level conditional type to allow distribution over props that are unions
4199type Defaultize<P, D> = P extends any ? string extends keyof P ? P
4200 :
4201 & Pick<P, Exclude<keyof P, keyof D>>
4202 & InexactPartial<Pick<P, Extract<keyof P, keyof D>>>
4203 & InexactPartial<Pick<D, Exclude<keyof D, keyof P>>>
4204 : never;
4205
4206type ReactManagedAttributes<C, P> = C extends { defaultProps: infer D } ? Defaultize<P, D>
4207 : P;
4208
\No newline at end of file