UNPKG

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