/**
* These are types for things that are present in the React `canary` release channel.
*
* To load the types declared here in an actual project, there are three ways. The easiest one,
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
* is to add `"react/canary"` to the `"types"` array.
*
* Alternatively, a specific import syntax can to be used from a typescript file.
* This module does not exist in reality, which is why the {} is important:
*
* ```ts
* import {} from 'react/canary'
* ```
*
* It is also possible to include it through a triple-slash reference:
*
* ```ts
* ///
* ```
*
* Either the import or the reference only needs to appear once, anywhere in the project.
*/
// See https://github.com/facebook/react/blob/main/packages/react/src/React.js to see how the exports are declared,
import React = require(".");
export {};
declare const UNDEFINED_VOID_ONLY: unique symbol;
type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
type NativeToggleEvent = ToggleEvent;
declare module "." {
export type Usable = PromiseLike | Context;
export function use(usable: Usable): T;
interface ServerContextJSONArray extends ReadonlyArray {}
export type ServerContextJSONValue =
| string
| boolean
| number
| null
| ServerContextJSONArray
| { [key: string]: ServerContextJSONValue };
export interface ServerContext {
Provider: Provider;
}
/**
* Accepts a context object (the value returned from `React.createContext` or `React.createServerContext`) and returns the current
* context value, as given by the nearest context provider for the given context.
*
* @version 16.8.0
* @see https://react.dev/reference/react/useContext
*/
function useContext(context: ServerContext): T;
export function createServerContext(
globalName: string,
defaultValue: T,
): ServerContext;
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
export function cache(fn: CachedFunction): CachedFunction;
export function unstable_useCacheRefresh(): () => void;
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS {
functions: (formData: FormData) => void | Promise;
}
export interface TransitionStartFunction {
/**
* Marks all state updates inside the async function as transitions
*
* @see {https://react.dev/reference/react/useTransition#starttransition}
*
* @param callback
*/
(callback: () => Promise): void;
}
/**
* Similar to `useTransition` but allows uses where hooks are not available.
*
* @param callback An _asynchronous_ function which causes state updates that can be deferred.
*/
export function startTransition(scope: () => Promise): void;
export function useOptimistic(
passthrough: State,
): [State, (action: State | ((pendingState: State) => State)) => void];
export function useOptimistic(
passthrough: State,
reducer: (state: State, action: Action) => State,
): [State, (action: Action) => void];
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES {
cleanup: () => VoidOrUndefinedOnly;
}
export function useActionState(
action: (state: Awaited) => State | Promise,
initialState: Awaited,
permalink?: string,
): [state: Awaited, dispatch: () => void, isPending: boolean];
export function useActionState(
action: (state: Awaited, payload: Payload) => State | Promise,
initialState: Awaited,
permalink?: string,
): [state: Awaited, dispatch: (payload: Payload) => void, isPending: boolean];
interface DOMAttributes {
// Transition Events
onTransitionCancel?: TransitionEventHandler | undefined;
onTransitionCancelCapture?: TransitionEventHandler | undefined;
onTransitionRun?: TransitionEventHandler | undefined;
onTransitionRunCapture?: TransitionEventHandler | undefined;
onTransitionStart?: TransitionEventHandler | undefined;
onTransitionStartCapture?: TransitionEventHandler | undefined;
}
type ToggleEventHandler = EventHandler>;
interface HTMLAttributes {
popover?: "" | "auto" | "manual" | undefined;
popoverTargetAction?: "toggle" | "show" | "hide" | undefined;
popoverTarget?: string | undefined;
onToggle?: ToggleEventHandler | undefined;
onBeforeToggle?: ToggleEventHandler | undefined;
}
interface ToggleEvent extends SyntheticEvent {
oldState: "closed" | "open";
newState: "closed" | "open";
}
interface LinkHTMLAttributes {
precedence?: string | undefined;
}
interface StyleHTMLAttributes {
href?: string | undefined;
precedence?: string | undefined;
}
/**
* @internal Use `Awaited` instead
*/
// Helper type to enable `Awaited`.
// Must be a copy of the non-thenables of `ReactNode`.
type AwaitedReactNode =
| ReactElement
| string
| number
| Iterable
| ReactPortal
| boolean
| null
| undefined;
interface DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_REACT_NODES {
promises: Promise;
bigints: bigint;
}
}