UNPKG

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