\n// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n// TypeScript Version: 2.8\n\n// NOTE: Users of the `experimental` builds of React should add a reference\n// to 'react/experimental' in their project. See experimental.d.ts's top comment\n// for reference and documentation on how exactly to do it.\n\n/// \n\nimport * as CSS from 'csstype';\nimport * as PropTypes from 'prop-types';\nimport { Interaction as SchedulerInteraction } from 'scheduler/tracing';\n\ntype NativeAnimationEvent = AnimationEvent;\ntype NativeClipboardEvent = ClipboardEvent;\ntype NativeCompositionEvent = CompositionEvent;\ntype NativeDragEvent = DragEvent;\ntype NativeFocusEvent = FocusEvent;\ntype NativeKeyboardEvent = KeyboardEvent;\ntype NativeMouseEvent = MouseEvent;\ntype NativeTouchEvent = TouchEvent;\ntype NativePointerEvent = PointerEvent;\ntype NativeTransitionEvent = TransitionEvent;\ntype NativeUIEvent = UIEvent;\ntype NativeWheelEvent = WheelEvent;\ntype Booleanish = boolean | 'true' | 'false';\ntype CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined;\n\ndeclare const UNDEFINED_VOID_ONLY: unique symbol;\n// Destructors are only allowed to return void.\ntype Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never };\ntype VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };\n\n// eslint-disable-next-line @definitelytyped/export-just-namespace\nexport = React;\nexport as namespace React;\n\ndeclare namespace React {\n //\n // React Elements\n // ----------------------------------------------------------------------\n\n type ElementType =\n {\n [K in keyof JSX.IntrinsicElements]: P extends JSX.IntrinsicElements[K] ? K : never\n }[keyof JSX.IntrinsicElements] |\n ComponentType
;\n type ComponentType
= ComponentClass
| FunctionComponent
;\n\n type JSXElementConstructor
=\n | ((\n props: P,\n /**\n * @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components\n */\n deprecatedLegacyContext?: any,\n ) => ReactNode)\n | (new (\n props: P,\n /**\n * @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods\n */\n deprecatedLegacyContext?: any,\n ) => Component);\n\n interface RefObject {\n readonly current: T | null;\n }\n // Bivariance hack for consistent unsoundness with RefObject\n type RefCallback = { bivarianceHack(instance: T | null): void }[\"bivarianceHack\"];\n type Ref = RefCallback | RefObject | null;\n type LegacyRef = string | Ref;\n /**\n * Gets the instance type for a React element. The instance will be different for various component types:\n *\n * - React class components will be the class instance. So if you had `class Foo extends React.Component<{}> {}`\n * and used `React.ElementRef` then the type would be the instance of `Foo`.\n * - React stateless functional components do not have a backing instance and so `React.ElementRef`\n * (when `Bar` is `function Bar() {}`) will give you the `undefined` type.\n * - JSX intrinsics like `div` will give you their DOM instance. For `React.ElementRef<'div'>` that would be\n * `HTMLDivElement`. For `React.ElementRef<'input'>` that would be `HTMLInputElement`.\n * - React stateless functional components that forward a `ref` will give you the `ElementRef` of the forwarded\n * to component.\n *\n * `C` must be the type _of_ a React component so you need to use typeof as in `React.ElementRef`.\n *\n * @todo In Flow, this works a little different with forwarded refs and the `AbstractComponent` that\n * `React.forwardRef()` returns.\n */\n type ElementRef<\n C extends\n | ForwardRefExoticComponent\n | { new (props: any): Component }\n | ((props: any, context?: any) => ReactNode)\n | keyof JSX.IntrinsicElements\n > =\n // need to check first if `ref` is a valid prop for ts@3.0\n // otherwise it will infer `{}` instead of `never`\n \"ref\" extends keyof ComponentPropsWithRef\n ? NonNullable[\"ref\"]> extends Ref<\n infer Instance\n >\n ? Instance\n : never\n : never;\n\n type ComponentState = any;\n\n type Key = string | number;\n\n /**\n * @internal You shouldn't need to use this type since you never see these attributes\n * inside your component or have to validate them.\n */\n interface Attributes {\n key?: Key | null | undefined;\n }\n interface RefAttributes extends Attributes {\n /**\n * Allows getting a ref to the component instance.\n * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).\n * @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom\n */\n ref?: Ref | undefined;\n }\n interface ClassAttributes extends Attributes {\n /**\n * Allows getting a ref to the component instance.\n * Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref).\n * @see https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom\n */\n ref?: LegacyRef | undefined;\n }\n\n interface ReactElement = string | JSXElementConstructor> {\n type: T;\n props: P;\n key: Key | null;\n }\n\n interface ReactComponentElement<\n T extends keyof JSX.IntrinsicElements | JSXElementConstructor,\n P = Pick, Exclude, 'key' | 'ref'>>\n > extends ReactElement> { }\n\n interface FunctionComponentElement
extends ReactElement
> {\n ref?: ('ref' extends keyof P ? P extends { ref?: infer R | undefined } ? R : never : never) | undefined;\n }\n\n type CElement
> = ComponentElement
;\n interface ComponentElement
> extends ReactElement
> {\n ref?: LegacyRef | undefined;\n }\n\n type ClassicElement = CElement
>;\n\n // string fallback for custom web-components\n interface DOMElement
| SVGAttributes, T extends Element> extends ReactElement {\n ref: LegacyRef;\n }\n\n // ReactHTML for ReactHTMLElement\n interface ReactHTMLElement extends DetailedReactHTMLElement, T> { }\n\n interface DetailedReactHTMLElement, T extends HTMLElement> extends DOMElement
{\n type: keyof ReactHTML;\n }\n\n // ReactSVG for ReactSVGElement\n interface ReactSVGElement extends DOMElement, SVGElement> {\n type: keyof ReactSVG;\n }\n\n interface ReactPortal extends ReactElement {\n key: Key | null;\n children: ReactNode;\n }\n\n //\n // Factories\n // ----------------------------------------------------------------------\n\n type Factory = (props?: Attributes & P, ...children: ReactNode[]) => ReactElement
;\n\n /**\n * @deprecated Please use `FunctionComponentFactory`\n */\n type SFCFactory
= FunctionComponentFactory
;\n\n type FunctionComponentFactory
= (props?: Attributes & P, ...children: ReactNode[]) => FunctionComponentElement
;\n\n type ComponentFactory
> =\n (props?: ClassAttributes & P, ...children: ReactNode[]) => CElement;\n\n type CFactory
> = ComponentFactory
;\n type ClassicFactory
= CFactory
>;\n\n type DOMFactory
, T extends Element> =\n (props?: ClassAttributes & P | null, ...children: ReactNode[]) => DOMElement;\n\n interface HTMLFactory extends DetailedHTMLFactory, T> {}\n\n interface DetailedHTMLFactory, T extends HTMLElement> extends DOMFactory
{\n (props?: ClassAttributes & P | null, ...children: ReactNode[]): DetailedReactHTMLElement;\n }\n\n interface SVGFactory extends DOMFactory, SVGElement> {\n (props?: ClassAttributes & SVGAttributes | null, ...children: ReactNode[]): ReactSVGElement;\n }\n\n /**\n * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.\n */\n type ReactText = string | number;\n /**\n * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.\n */\n type ReactChild = ReactElement | string | number;\n\n /**\n * @deprecated Use either `ReactNode[]` if you need an array or `Iterable` if its passed to a host component.\n */\n interface ReactNodeArray extends ReadonlyArray {}\n /**\n * @deprecated - This type is not relevant when using React. Inline the type instead to make the intent clear.\n */\n type ReactFragment = Iterable;\n\n /**\n * For internal usage only.\n * Different release channels declare additional types of ReactNode this particular release channel accepts.\n * App or library types should never augment this interface.\n */\n interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {}\n type ReactNode =\n | ReactElement\n | string\n | number\n | Iterable\n | ReactPortal\n | boolean\n | null\n | undefined\n | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES];\n\n //\n // Top Level API\n // ----------------------------------------------------------------------\n\n // DOM Elements\n function createFactory(\n type: keyof ReactHTML): HTMLFactory;\n function createFactory(\n type: keyof ReactSVG): SVGFactory;\n function createFactory, T extends Element>(\n type: string): DOMFactory
;\n\n // Custom components\n function createFactory
(type: FunctionComponent
): FunctionComponentFactory
;\n function createFactory
(\n type: ClassType
, ClassicComponentClass
>): CFactory
>;\n function createFactory
, C extends ComponentClass
>(\n type: ClassType
): CFactory
;\n function createFactory
(type: ComponentClass
): Factory
;\n\n // DOM Elements\n // TODO: generalize this to everything in `keyof ReactHTML`, not just \"input\"\n function createElement(\n type: \"input\",\n props?: InputHTMLAttributes & ClassAttributes | null,\n ...children: ReactNode[]): DetailedReactHTMLElement, HTMLInputElement>;\n function createElement, T extends HTMLElement>(\n type: keyof ReactHTML,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]): DetailedReactHTMLElement;\n function createElement
, T extends SVGElement>(\n type: keyof ReactSVG,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]): ReactSVGElement;\n function createElement, T extends Element>(\n type: string,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]): DOMElement;\n\n // Custom components\n\n function createElement
(\n type: FunctionComponent
,\n props?: Attributes & P | null,\n ...children: ReactNode[]): FunctionComponentElement
;\n function createElement
(\n type: ClassType
, ClassicComponentClass
>,\n props?: ClassAttributes> & P | null,\n ...children: ReactNode[]): CElement>;\n function createElement
, C extends ComponentClass
>(\n type: ClassType
,\n props?: ClassAttributes & P | null,\n ...children: ReactNode[]): CElement;\n function createElement
(\n type: FunctionComponent
| ComponentClass
| string,\n props?: Attributes & P | null,\n ...children: ReactNode[]): ReactElement
;\n\n // DOM Elements\n // ReactHTMLElement\n function cloneElement
, T extends HTMLElement>(\n element: DetailedReactHTMLElement
,\n props?: P,\n ...children: ReactNode[]): DetailedReactHTMLElement
;\n // ReactHTMLElement, less specific\n function cloneElement
, T extends HTMLElement>(\n element: ReactHTMLElement,\n props?: P,\n ...children: ReactNode[]): ReactHTMLElement;\n // SVGElement\n function cloneElement, T extends SVGElement>(\n element: ReactSVGElement,\n props?: P,\n ...children: ReactNode[]): ReactSVGElement;\n // DOM Element (has to be the last, because type checking stops at first overload that fits)\n function cloneElement
, T extends Element>(\n element: DOMElement
,\n props?: DOMAttributes & P,\n ...children: ReactNode[]): DOMElement;\n\n // Custom components\n function cloneElement
(\n element: FunctionComponentElement
,\n props?: Partial
& Attributes,\n ...children: ReactNode[]): FunctionComponentElement
;\n function cloneElement
>(\n element: CElement
,\n props?: Partial
& ClassAttributes,\n ...children: ReactNode[]): CElement;\n function cloneElement
(\n element: ReactElement
,\n props?: Partial
& Attributes,\n ...children: ReactNode[]): ReactElement
;\n\n // Context via RenderProps\n interface ProviderProps {\n value: T;\n children?: ReactNode | undefined;\n }\n\n interface ConsumerProps {\n children: (value: T) => ReactNode;\n }\n\n // TODO: similar to how Fragment is actually a symbol, the values returned from createContext,\n // forwardRef and memo are actually objects that are treated specially by the renderer; see:\n // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/ReactContext.js#L35-L48\n // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/forwardRef.js#L42-L45\n // https://github.com/facebook/react/blob/v16.6.0/packages/react/src/memo.js#L27-L31\n // However, we have no way of telling the JSX parser that it's a JSX element type or its props other than\n // by pretending to be a normal component.\n //\n // We don't just use ComponentType or FunctionComponent types because you are not supposed to attach statics to this\n // object, but rather to the original function.\n interface ExoticComponent {\n /**\n * **NOTE**: Exotic components are not callable.\n */\n (props: P): ReactNode;\n readonly $$typeof: symbol;\n }\n\n interface NamedExoticComponent
extends ExoticComponent
{\n displayName?: string | undefined;\n }\n\n interface ProviderExoticComponent
extends ExoticComponent
{\n propTypes?: WeakValidationMap
| undefined;\n }\n\n type ContextType> = C extends Context ? T : never;\n\n // NOTE: only the Context object itself can get a displayName\n // https://github.com/facebook/react-devtools/blob/e0b854e4c/backend/attachRendererFiber.js#L310-L325\n type Provider = ProviderExoticComponent>;\n type Consumer = ExoticComponent>;\n interface Context {\n Provider: Provider;\n Consumer: Consumer;\n displayName?: string | undefined;\n }\n function createContext(\n // If you thought this should be optional, see\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106\n defaultValue: T,\n ): Context;\n\n function isValidElement(object: {} | null | undefined): object is ReactElement
;\n\n // Sync with `ReactChildren` until `ReactChildren` is removed.\n const Children: {\n map(children: C | ReadonlyArray, fn: (child: C, index: number) => T):\n C extends null | undefined ? C : Array>;\n forEach(children: C | ReadonlyArray, fn: (child: C, index: number) => void): void;\n count(children: any): number;\n only(children: C): C extends any[] ? never : C;\n toArray(children: ReactNode | ReactNode[]): Array>;\n };\n const Fragment: ExoticComponent<{ children?: ReactNode | undefined }>;\n const StrictMode: ExoticComponent<{ children?: ReactNode | undefined }>;\n\n interface SuspenseProps {\n children?: ReactNode | undefined;\n\n /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */\n fallback?: ReactNode;\n }\n\n const Suspense: ExoticComponent;\n const version: string;\n\n /**\n * {@link https://react.dev/reference/react/Profiler#onrender-callback Profiler API}\n */\n type ProfilerOnRenderCallback = (\n id: string,\n phase: \"mount\" | \"update\",\n actualDuration: number,\n baseDuration: number,\n startTime: number,\n commitTime: number,\n interactions: Set,\n ) => void;\n interface ProfilerProps {\n children?: ReactNode | undefined;\n id: string;\n onRender: ProfilerOnRenderCallback;\n }\n\n const Profiler: ExoticComponent;\n\n //\n // Component API\n // ----------------------------------------------------------------------\n\n type ReactInstance = Component | Element;\n\n // Base component for plain JS classes\n interface Component extends ComponentLifecycle
{ }\n class Component
{\n // tslint won't let me format the sample code in a way that vscode likes it :(\n /**\n * If set, `this.context` will be set at runtime to the current value of the given Context.\n *\n * Usage:\n *\n * ```ts\n * type MyContext = number\n * const Ctx = React.createContext(0)\n *\n * class Foo extends React.Component {\n * static contextType = Ctx\n * context!: React.ContextType\n * render () {\n * return <>My context's value: {this.context}>;\n * }\n * }\n * ```\n *\n * @see https://react.dev/reference/react/Component#static-contexttype\n */\n static contextType?: Context | undefined;\n\n /**\n * If using the new style context, re-declare this in your class to be the\n * `React.ContextType` of your `static contextType`.\n * Should be used with type annotation or static contextType.\n *\n * ```ts\n * static contextType = MyContext\n * // For TS pre-3.7:\n * context!: React.ContextType\n * // For TS 3.7 and above:\n * declare context: React.ContextType\n * ```\n *\n * @see https://react.dev/reference/react/Component#context\n */\n context: unknown;\n\n constructor(props: Readonly | P);\n /**\n * @deprecated\n * @see https://legacy.reactjs.org/docs/legacy-context.html\n */\n constructor(props: P, context: any);\n\n // We MUST keep setState() as a unified signature because it allows proper checking of the method return type.\n // See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365#issuecomment-351013257\n // Also, the ` | S` allows intellisense to not be dumbisense\n setState(\n state: ((prevState: Readonly, props: Readonly) => (Pick | S | null)) | (Pick | S | null),\n callback?: () => void\n ): void;\n\n forceUpdate(callback?: () => void): void;\n render(): ReactNode;\n\n readonly props: Readonly
;\n state: Readonly;\n /**\n * @deprecated\n * https://legacy.reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs\n */\n refs: {\n [key: string]: ReactInstance\n };\n }\n\n class PureComponent
extends Component
{ }\n\n interface ClassicComponent
extends Component
{\n replaceState(nextState: S, callback?: () => void): void;\n isMounted(): boolean;\n getInitialState?(): S;\n }\n\n interface ChildContextProvider {\n getChildContext(): CC;\n }\n\n //\n // Class Interfaces\n // ----------------------------------------------------------------------\n\n type FC = FunctionComponent
;\n\n interface FunctionComponent
{\n (props: P, context?: any): ReactNode;\n propTypes?: WeakValidationMap
| undefined;\n contextTypes?: ValidationMap | undefined;\n defaultProps?: Partial | undefined;\n displayName?: string | undefined;\n }\n\n /**\n * @deprecated - Equivalent with `React.FC`.\n */\n type VFC
= VoidFunctionComponent
;\n\n /**\n * @deprecated - Equivalent with `React.FunctionComponent`.\n */\n interface VoidFunctionComponent
{\n (props: P, context?: any): ReactNode;\n propTypes?: WeakValidationMap
| undefined;\n contextTypes?: ValidationMap | undefined;\n defaultProps?: Partial | undefined;\n displayName?: string | undefined;\n }\n\n type ForwardedRef = ((instance: T | null) => void) | MutableRefObject | null;\n\n interface ForwardRefRenderFunction {\n (props: P, ref: ForwardedRef): ReactNode;\n displayName?: string | undefined;\n // explicit rejected with `never` required due to\n // https://github.com/microsoft/TypeScript/issues/36826\n /**\n * defaultProps are not supported on render functions\n */\n defaultProps?: never | undefined;\n /**\n * propTypes are not supported on render functions\n */\n propTypes?: never | undefined;\n }\n\n interface ComponentClass extends StaticLifecycle
{\n new (props: P, context?: any): Component
;\n propTypes?: WeakValidationMap
| undefined;\n contextType?: Context | undefined;\n contextTypes?: ValidationMap | undefined;\n childContextTypes?: ValidationMap | undefined;\n defaultProps?: Partial | undefined;\n displayName?: string | undefined;\n }\n\n interface ClassicComponentClass
extends ComponentClass
{\n new (props: P, context?: any): ClassicComponent
;\n getDefaultProps?(): P;\n }\n\n /**\n * We use an intersection type to infer multiple type parameters from\n * a single argument, which is useful for many top-level API defs.\n * See https://github.com/Microsoft/TypeScript/issues/7234 for more info.\n */\n type ClassType
, C extends ComponentClass
> =\n C &\n (new (props: P, context?: any) => T);\n\n //\n // Component Specs and Lifecycle\n // ----------------------------------------------------------------------\n\n // This should actually be something like `Lifecycle
| DeprecatedLifecycle
`,\n // as React will _not_ call the deprecated lifecycle methods if any of the new lifecycle\n // methods are present.\n interface ComponentLifecycle
extends NewLifecycle
, DeprecatedLifecycle
{\n /**\n * Called immediately after a component is mounted. Setting state here will trigger re-rendering.\n */\n componentDidMount?(): void;\n /**\n * Called to determine whether the change in props and state should trigger a re-render.\n *\n * `Component` always returns true.\n * `PureComponent` implements a shallow comparison on props and state and returns true if any\n * props or states have changed.\n *\n * If false is returned, `Component#render`, `componentWillUpdate`\n * and `componentDidUpdate` will not be called.\n */\n shouldComponentUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): boolean;\n /**\n * Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as\n * cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.\n */\n componentWillUnmount?(): void;\n /**\n * Catches exceptions generated in descendant components. Unhandled exceptions will cause\n * the entire component tree to unmount.\n */\n componentDidCatch?(error: Error, errorInfo: ErrorInfo): void;\n }\n\n // Unfortunately, we have no way of declaring that the component constructor must implement this\n interface StaticLifecycle
{\n getDerivedStateFromProps?: GetDerivedStateFromProps
| undefined;\n getDerivedStateFromError?: GetDerivedStateFromError
| undefined;\n }\n\n type GetDerivedStateFromProps
=\n /**\n * Returns an update to a component's state based on its new props and old state.\n *\n * Note: its presence prevents any of the deprecated lifecycle methods from being invoked\n */\n (nextProps: Readonly
, prevState: S) => Partial | null;\n\n type GetDerivedStateFromError
=\n /**\n * This lifecycle is invoked after an error has been thrown by a descendant component.\n * It receives the error that was thrown as a parameter and should return a value to update state.\n *\n * Note: its presence prevents any of the deprecated lifecycle methods from being invoked\n */\n (error: any) => Partial | null;\n\n // This should be \"infer SS\" but can't use it yet\n interface NewLifecycle
{\n /**\n * Runs before React applies the result of `render` to the document, and\n * returns an object to be given to componentDidUpdate. Useful for saving\n * things such as scroll position before `render` causes changes to it.\n *\n * Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated\n * lifecycle events from running.\n */\n getSnapshotBeforeUpdate?(prevProps: Readonly
, prevState: Readonly): SS | null;\n /**\n * Called immediately after updating occurs. Not called for the initial render.\n *\n * The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.\n */\n componentDidUpdate?(prevProps: Readonly
, prevState: Readonly, snapshot?: SS): void;\n }\n\n interface DeprecatedLifecycle
{\n /**\n * Called immediately before mounting occurs, and before `Component#render`.\n * Avoid introducing any side-effects or subscriptions in this method.\n *\n * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps\n * prevents this from being invoked.\n *\n * @deprecated 16.3, use componentDidMount or the constructor instead; will stop working in React 17\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path\n */\n componentWillMount?(): void;\n /**\n * Called immediately before mounting occurs, and before `Component#render`.\n * Avoid introducing any side-effects or subscriptions in this method.\n *\n * This method will not stop working in React 17.\n *\n * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps\n * prevents this from being invoked.\n *\n * @deprecated 16.3, use componentDidMount or the constructor instead\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#initializing-state\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path\n */\n UNSAFE_componentWillMount?(): void;\n /**\n * Called when the component may be receiving new props.\n * React may call this even if props have not changed, so be sure to compare new and existing\n * props if you only want to handle changes.\n *\n * Calling `Component#setState` generally does not trigger this method.\n *\n * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps\n * prevents this from being invoked.\n *\n * @deprecated 16.3, use static getDerivedStateFromProps instead; will stop working in React 17\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path\n */\n componentWillReceiveProps?(nextProps: Readonly
, nextContext: any): void;\n /**\n * Called when the component may be receiving new props.\n * React may call this even if props have not changed, so be sure to compare new and existing\n * props if you only want to handle changes.\n *\n * Calling `Component#setState` generally does not trigger this method.\n *\n * This method will not stop working in React 17.\n *\n * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps\n * prevents this from being invoked.\n *\n * @deprecated 16.3, use static getDerivedStateFromProps instead\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#updating-state-based-on-props\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path\n */\n UNSAFE_componentWillReceiveProps?(nextProps: Readonly
, nextContext: any): void;\n /**\n * Called immediately before rendering when new props or state is received. Not called for the initial render.\n *\n * Note: You cannot call `Component#setState` here.\n *\n * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps\n * prevents this from being invoked.\n *\n * @deprecated 16.3, use getSnapshotBeforeUpdate instead; will stop working in React 17\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path\n */\n componentWillUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): void;\n /**\n * Called immediately before rendering when new props or state is received. Not called for the initial render.\n *\n * Note: You cannot call `Component#setState` here.\n *\n * This method will not stop working in React 17.\n *\n * Note: the presence of getSnapshotBeforeUpdate or getDerivedStateFromProps\n * prevents this from being invoked.\n *\n * @deprecated 16.3, use getSnapshotBeforeUpdate instead\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#reading-dom-properties-before-an-update\n * @see https://legacy.reactjs.org/blog/2018/03/27/update-on-async-rendering.html#gradual-migration-path\n */\n UNSAFE_componentWillUpdate?(nextProps: Readonly
, nextState: Readonly, nextContext: any): void;\n }\n\n interface Mixin
extends ComponentLifecycle
{\n mixins?: Array> | undefined;\n statics?: {\n [key: string]: any;\n } | undefined;\n\n displayName?: string | undefined;\n propTypes?: ValidationMap | undefined;\n contextTypes?: ValidationMap | undefined;\n childContextTypes?: ValidationMap | undefined;\n\n getDefaultProps?(): P;\n getInitialState?(): S;\n }\n\n interface ComponentSpec extends Mixin
{\n render(): ReactNode;\n\n [propertyName: string]: any;\n }\n\n function createRef(): RefObject;\n\n // will show `ForwardRef(${Component.displayName || Component.name})` in devtools by default,\n // but can be given its own specific name\n interface ForwardRefExoticComponent extends NamedExoticComponent
{\n defaultProps?: Partial
| undefined;\n propTypes?: WeakValidationMap
| undefined;\n }\n\n function forwardRef(render: ForwardRefRenderFunction): ForwardRefExoticComponent & RefAttributes>;\n\n /** Ensures that the props do not include ref at all */\n type PropsWithoutRef =\n // Omit would not be sufficient for this. We'd like to avoid unnecessary mapping and need a distributive conditional to support unions.\n // see: https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n // https://github.com/Microsoft/TypeScript/issues/28339\n P extends any ? ('ref' extends keyof P ? Omit
: P) : P;\n /** Ensures that the props do not include string ref, which cannot be forwarded */\n type PropsWithRef
=\n // Just \"P extends { ref?: infer R }\" looks sufficient, but R will infer as {} if P is {}.\n 'ref' extends keyof P\n ? P extends { ref?: infer R | undefined }\n ? string extends R\n ? PropsWithoutRef
& { ref?: Exclude | undefined }\n : P\n : P\n : P;\n\n type PropsWithChildren = P & { children?: ReactNode | undefined };\n\n /**\n * NOTE: prefer ComponentPropsWithRef, if the ref is forwarded,\n * or ComponentPropsWithoutRef when refs are not supported.\n */\n type ComponentProps> =\n T extends JSXElementConstructor\n ? P\n : T extends keyof JSX.IntrinsicElements\n ? JSX.IntrinsicElements[T]\n : {};\n type ComponentPropsWithRef =\n T extends (new (props: infer P) => Component)\n ? PropsWithoutRef & RefAttributes>\n : PropsWithRef>;\n type ComponentPropsWithoutRef =\n PropsWithoutRef>;\n\n type ComponentRef = T extends NamedExoticComponent<\n ComponentPropsWithoutRef & RefAttributes\n >\n ? Method\n : ComponentPropsWithRef extends RefAttributes\n ? Method\n : never;\n\n // will show `Memo(${Component.displayName || Component.name})` in devtools by default,\n // but can be given its own specific name\n type MemoExoticComponent> = NamedExoticComponent> & {\n readonly type: T;\n };\n\n function memo(\n Component: FunctionComponent
,\n propsAreEqual?: (prevProps: Readonly
, nextProps: Readonly
) => boolean\n ): NamedExoticComponent
;\n function memo>(\n Component: T,\n propsAreEqual?: (prevProps: Readonly>, nextProps: Readonly>) => boolean\n ): MemoExoticComponent;\n\n type LazyExoticComponent> = ExoticComponent> & {\n readonly _result: T;\n };\n\n function lazy>(\n factory: () => Promise<{ default: T }>\n ): LazyExoticComponent;\n\n //\n // React Hooks\n // ----------------------------------------------------------------------\n\n // based on the code in https://github.com/facebook/react/pull/13968\n\n // Unlike the class component setState, the updates are not allowed to be partial\n type SetStateAction = S | ((prevState: S) => S);\n // this technically does accept a second argument, but it's already under a deprecation warning\n // and it's not even released so probably better to not define it.\n type Dispatch = (value: A) => void;\n // Since action _can_ be undefined, dispatch may be called without any parameters.\n type DispatchWithoutAction = () => void;\n // Unlike redux, the actions _can_ be anything\n type Reducer = (prevState: S, action: A) => S;\n // If useReducer accepts a reducer without action, dispatch may be called without any parameters.\n type ReducerWithoutAction = (prevState: S) => S;\n // types used to try and prevent the compiler from reducing S\n // to a supertype common with the second argument to useReducer()\n type ReducerState> = R extends Reducer ? S : never;\n type ReducerAction> = R extends Reducer ? A : never;\n // The identity check is done with the SameValue algorithm (Object.is), which is stricter than ===\n type ReducerStateWithoutAction> =\n R extends ReducerWithoutAction ? S : never;\n type DependencyList = ReadonlyArray;\n\n // NOTE: callbacks are _only_ allowed to return either void, or a destructor.\n type EffectCallback = () => (void | Destructor);\n\n interface MutableRefObject {\n current: T;\n }\n\n // This will technically work if you give a Consumer or Provider but it's deprecated and warns\n /**\n * Accepts a context object (the value returned from `React.createContext`) and returns the current\n * context value, as given by the nearest context provider for the given context.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useContext\n */\n function useContext(context: Context/*, (not public API) observedBits?: number|boolean */): T;\n /**\n * Returns a stateful value, and a function to update it.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useState\n */\n function useState(initialState: S | (() => S)): [S, Dispatch>];\n // convenience overload when first argument is omitted\n /**\n * Returns a stateful value, and a function to update it.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useState\n */\n function useState(): [S | undefined, Dispatch>];\n /**\n * An alternative to `useState`.\n *\n * `useReducer` is usually preferable to `useState` when you have complex state logic that involves\n * multiple sub-values. It also lets you optimize performance for components that trigger deep\n * updates because you can pass `dispatch` down instead of callbacks.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useReducer\n */\n // overload where dispatch could accept 0 arguments.\n function useReducer, I>(\n reducer: R,\n initializerArg: I,\n initializer: (arg: I) => ReducerStateWithoutAction\n ): [ReducerStateWithoutAction, DispatchWithoutAction];\n /**\n * An alternative to `useState`.\n *\n * `useReducer` is usually preferable to `useState` when you have complex state logic that involves\n * multiple sub-values. It also lets you optimize performance for components that trigger deep\n * updates because you can pass `dispatch` down instead of callbacks.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useReducer\n */\n // overload where dispatch could accept 0 arguments.\n function useReducer>(\n reducer: R,\n initializerArg: ReducerStateWithoutAction,\n initializer?: undefined\n ): [ReducerStateWithoutAction, DispatchWithoutAction];\n /**\n * An alternative to `useState`.\n *\n * `useReducer` is usually preferable to `useState` when you have complex state logic that involves\n * multiple sub-values. It also lets you optimize performance for components that trigger deep\n * updates because you can pass `dispatch` down instead of callbacks.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useReducer\n */\n // overload where \"I\" may be a subset of ReducerState; used to provide autocompletion.\n // If \"I\" matches ReducerState exactly then the last overload will allow initializer to be omitted.\n // the last overload effectively behaves as if the identity function (x => x) is the initializer.\n function useReducer, I>(\n reducer: R,\n initializerArg: I & ReducerState,\n initializer: (arg: I & ReducerState) => ReducerState\n ): [ReducerState, Dispatch>];\n /**\n * An alternative to `useState`.\n *\n * `useReducer` is usually preferable to `useState` when you have complex state logic that involves\n * multiple sub-values. It also lets you optimize performance for components that trigger deep\n * updates because you can pass `dispatch` down instead of callbacks.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useReducer\n */\n // overload for free \"I\"; all goes as long as initializer converts it into \"ReducerState\".\n function useReducer, I>(\n reducer: R,\n initializerArg: I,\n initializer: (arg: I) => ReducerState\n ): [ReducerState, Dispatch>];\n /**\n * An alternative to `useState`.\n *\n * `useReducer` is usually preferable to `useState` when you have complex state logic that involves\n * multiple sub-values. It also lets you optimize performance for components that trigger deep\n * updates because you can pass `dispatch` down instead of callbacks.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useReducer\n */\n\n // I'm not sure if I keep this 2-ary or if I make it (2,3)-ary; it's currently (2,3)-ary.\n // The Flow types do have an overload for 3-ary invocation with undefined initializer.\n\n // NOTE: without the ReducerState indirection, TypeScript would reduce S to be the most common\n // supertype between the reducer's return type and the initialState (or the initializer's return type),\n // which would prevent autocompletion from ever working.\n\n // TODO: double-check if this weird overload logic is necessary. It is possible it's either a bug\n // in older versions, or a regression in newer versions of the typescript completion service.\n function useReducer>(\n reducer: R,\n initialState: ReducerState,\n initializer?: undefined\n ): [ReducerState, Dispatch>];\n /**\n * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument\n * (`initialValue`). The returned object will persist for the full lifetime of the component.\n *\n * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable\n * value around similar to how you’d use instance fields in classes.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useRef\n */\n function useRef(initialValue: T): MutableRefObject;\n // convenience overload for refs given as a ref prop as they typically start with a null value\n /**\n * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument\n * (`initialValue`). The returned object will persist for the full lifetime of the component.\n *\n * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable\n * value around similar to how you’d use instance fields in classes.\n *\n * Usage note: if you need the result of useRef to be directly mutable, include `| null` in the type\n * of the generic argument.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useRef\n */\n function useRef(initialValue: T|null): RefObject;\n // convenience overload for potentially undefined initialValue / call with 0 arguments\n // has a default to stop it from defaulting to {} instead\n /**\n * `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument\n * (`initialValue`). The returned object will persist for the full lifetime of the component.\n *\n * Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable\n * value around similar to how you’d use instance fields in classes.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useRef\n */\n function useRef(): MutableRefObject;\n /**\n * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.\n * Use this to read layout from the DOM and synchronously re-render. Updates scheduled inside\n * `useLayoutEffect` will be flushed synchronously, before the browser has a chance to paint.\n *\n * Prefer the standard `useEffect` when possible to avoid blocking visual updates.\n *\n * If you’re migrating code from a class component, `useLayoutEffect` fires in the same phase as\n * `componentDidMount` and `componentDidUpdate`.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useLayoutEffect\n */\n function useLayoutEffect(effect: EffectCallback, deps?: DependencyList): void;\n /**\n * Accepts a function that contains imperative, possibly effectful code.\n *\n * @param effect Imperative function that can return a cleanup function\n * @param deps If present, effect will only activate if the values in the list change.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useEffect\n */\n function useEffect(effect: EffectCallback, deps?: DependencyList): void;\n // NOTE: this does not accept strings, but this will have to be fixed by removing strings from type Ref\n /**\n * `useImperativeHandle` customizes the instance value that is exposed to parent components when using\n * `ref`. As always, imperative code using refs should be avoided in most cases.\n *\n * `useImperativeHandle` should be used with `React.forwardRef`.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useImperativeHandle\n */\n function useImperativeHandle(ref: Ref|undefined, init: () => R, deps?: DependencyList): void;\n // I made 'inputs' required here and in useMemo as there's no point to memoizing without the memoization key\n // useCallback(X) is identical to just using X, useMemo(() => Y) is identical to just using Y.\n /**\n * `useCallback` will return a memoized version of the callback that only changes if one of the `inputs`\n * has changed.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useCallback\n */\n // A specific function type would not trigger implicit any.\n // See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/52873#issuecomment-845806435 for a comparison between `Function` and more specific types.\n // tslint:disable-next-line ban-types\n function useCallback(callback: T, deps: DependencyList): T;\n /**\n * `useMemo` will only recompute the memoized value when one of the `deps` has changed.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useMemo\n */\n // allow undefined, but don't make it optional as that is very likely a mistake\n function useMemo(factory: () => T, deps: DependencyList | undefined): T;\n /**\n * `useDebugValue` can be used to display a label for custom hooks in React DevTools.\n *\n * NOTE: We don’t recommend adding debug values to every custom hook.\n * It’s most valuable for custom hooks that are part of shared libraries.\n *\n * @version 16.8.0\n * @see https://react.dev/reference/react/useDebugValue\n */\n // the name of the custom hook is itself derived from the function name at runtime:\n // it's just the function name without the \"use\" prefix.\n function useDebugValue(value: T, format?: (value: T) => any): void;\n\n // must be synchronous\n export type TransitionFunction = () => VoidOrUndefinedOnly;\n // strange definition to allow vscode to show documentation on the invocation\n export interface TransitionStartFunction {\n /**\n * State updates caused inside the callback are allowed to be deferred.\n *\n * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**\n *\n * @param callback A _synchronous_ function which causes state updates that can be deferred.\n */\n (callback: TransitionFunction): void;\n }\n\n /**\n * Returns a deferred version of the value that may “lag behind” it.\n *\n * This is commonly used to keep the interface responsive when you have something that renders immediately\n * based on user input and something that needs to wait for a data fetch.\n *\n * A good example of this is a text input.\n *\n * @param value The value that is going to be deferred\n *\n * @see https://react.dev/reference/react/useDeferredValue\n */\n export function useDeferredValue(value: T): T;\n\n /**\n * Allows components to avoid undesirable loading states by waiting for content to load\n * before transitioning to the next screen. It also allows components to defer slower,\n * data fetching updates until subsequent renders so that more crucial updates can be\n * rendered immediately.\n *\n * The `useTransition` hook returns two values in an array.\n *\n * The first is a boolean, React’s way of informing us whether we’re waiting for the transition to finish.\n * The second is a function that takes a callback. We can use it to tell React which state we want to defer.\n *\n * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**`\n *\n * @see https://react.dev/reference/react/useTransition\n */\n export function useTransition(): [boolean, TransitionStartFunction];\n\n /**\n * Similar to `useTransition` but allows uses where hooks are not available.\n *\n * @param callback A _synchronous_ function which causes state updates that can be deferred.\n */\n export function startTransition(scope: TransitionFunction): void;\n\n export function useId(): string;\n\n /**\n * @param effect Imperative function that can return a cleanup function\n * @param deps If present, effect will only activate if the values in the list change.\n *\n * @see https://github.com/facebook/react/pull/21913\n */\n export function useInsertionEffect(effect: EffectCallback, deps?: DependencyList): void;\n\n /**\n * @param subscribe\n * @param getSnapshot\n *\n * @see https://github.com/reactwg/react-18/discussions/86\n */\n // keep in sync with `useSyncExternalStore` from `use-sync-external-store`\n export function useSyncExternalStore(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n ): Snapshot;\n\n //\n // Event System\n // ----------------------------------------------------------------------\n // TODO: change any to unknown when moving to TS v3\n interface BaseSyntheticEvent {\n nativeEvent: E;\n currentTarget: C;\n target: T;\n bubbles: boolean;\n cancelable: boolean;\n defaultPrevented: boolean;\n eventPhase: number;\n isTrusted: boolean;\n preventDefault(): void;\n isDefaultPrevented(): boolean;\n stopPropagation(): void;\n isPropagationStopped(): boolean;\n persist(): void;\n timeStamp: number;\n type: string;\n }\n\n /**\n * currentTarget - a reference to the element on which the event listener is registered.\n *\n * target - a reference to the element from which the event was originally dispatched.\n * This might be a child element to the element on which the event listener is registered.\n * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11508#issuecomment-256045682\n */\n interface SyntheticEvent extends BaseSyntheticEvent {}\n\n interface ClipboardEvent extends SyntheticEvent