npm package diff

Package: @types/react

Versions: 18.2.73 - 18.3.8

File: react/index.d.ts

Index: react/index.d.ts
===================================================================
--- react/index.d.ts
+++ react/index.d.ts
@@ -221,9 +221,9 @@
     type ElementRef<
         C extends
             | ForwardRefExoticComponent<any>
             | { new(props: any): Component<any> }
-            | ((props: any, context?: any) => ReactNode)
+            | ((props: any, deprecatedLegacyContext?: any) => ReactNode)
             | keyof JSX.IntrinsicElements,
     > =
         // need to check first if `ref` is a valid prop for [email protected]
         // otherwise it will infer `{}` instead of `never`
@@ -492,23 +492,29 @@
     // Top Level API
     // ----------------------------------------------------------------------
 
     // DOM Elements
+    /** @deprecated */
     function createFactory<T extends HTMLElement>(
         type: keyof ReactHTML,
     ): HTMLFactory<T>;
+    /** @deprecated */
     function createFactory(
         type: keyof ReactSVG,
     ): SVGFactory;
+    /** @deprecated */
     function createFactory<P extends DOMAttributes<T>, T extends Element>(
         type: string,
     ): DOMFactory<P, T>;
 
     // Custom components
+    /** @deprecated */
     function createFactory<P>(type: FunctionComponent<P>): FunctionComponentFactory<P>;
+    /** @deprecated */
     function createFactory<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>>(
         type: ClassType<P, T, C>,
     ): CFactory<P, T>;
+    /** @deprecated */
     function createFactory<P>(type: ComponentClass<P>): Factory<P>;
 
     // DOM Elements
     // TODO: generalize this to everything in `keyof ReactHTML`, not just "input"
@@ -841,8 +847,14 @@
         children?: ReactNode | undefined;
 
         /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
         fallback?: ReactNode;
+
+        /**
+         * A name for this Suspense boundary for instrumentation purposes.
+         * The name will help identify this boundary in React DevTools.
+         */
+        name?: string | undefined;
     }
 
     /**
      * Lets you display a fallback until its children have finished loading.
@@ -1104,9 +1116,17 @@
      * }
      * ```
      */
     interface FunctionComponent<P = {}> {
-        (props: P, context?: any): ReactNode;
+        (
+            props: P,
+            /**
+             * @deprecated
+             *
+             * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
+             */
+            deprecatedLegacyContext?: any,
+        ): ReactNode;
         /**
          * Used to declare the types of the props accepted by the
          * component. These types will be checked during rendering
          * and in development only.
@@ -1144,8 +1164,10 @@
          * MyComponent.defaultProps = {
          *   name: 'John Doe'
          * }
          * ```
+         *
+         * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
          */
         defaultProps?: Partial<P> | undefined;
         /**
          * Used in debugging messages. You might want to set it
@@ -1181,11 +1203,22 @@
      *
      * @see {@link React.FunctionComponent}
      */
     interface VoidFunctionComponent<P = {}> {
-        (props: P, context?: any): ReactNode;
+        (
+            props: P,
+            /**
+             * @deprecated
+             *
+             * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
+             */
+            deprecatedLegacyContext?: any,
+        ): ReactNode;
         propTypes?: WeakValidationMap<P> | undefined;
         contextTypes?: ValidationMap<any> | undefined;
+        /**
+         * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
+         */
         defaultProps?: Partial<P> | undefined;
         displayName?: string | undefined;
     }
 
@@ -1244,9 +1277,17 @@
      * @template P The props the component accepts.
      * @template S The internal state of the component.
      */
     interface ComponentClass<P = {}, S = ComponentState> extends StaticLifecycle<P, S> {
-        new(props: P, context?: any): Component<P, S>;
+        new(
+            props: P,
+            /**
+             * @deprecated
+             *
+             * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
+             */
+            deprecatedLegacyContext?: any,
+        ): Component<P, S>;
         /**
          * Used to declare the types of the props accepted by the
          * component. These types will be checked during rendering
          * and in development only.
@@ -1296,9 +1337,9 @@
      * @see {@link https://legacy.reactjs.org/docs/react-without-es6.html Legacy React Docs}
      * @see {@link https://www.npmjs.com/package/create-react-class `create-react-class` on npm}
      */
     interface ClassicComponentClass<P = {}> extends ComponentClass<P> {
-        new(props: P, context?: any): ClassicComponent<P, ComponentState>;
+        new(props: P, deprecatedLegacyContext?: any): ClassicComponent<P, ComponentState>;
         getDefaultProps?(): P;
     }
 
     /**
@@ -1311,9 +1352,9 @@
      * for more info.
      */
     type ClassType<P, T extends Component<P, ComponentState>, C extends ComponentClass<P>> =
         & C
-        & (new(props: P, context?: any) => T);
+        & (new(props: P, deprecatedLegacyContext?: any) => T);
 
     //
     // Component Specs and Lifecycle
     // ----------------------------------------------------------------------
@@ -1526,8 +1567,11 @@
      *
      * @see {@link ExoticComponent}
      */
     interface ForwardRefExoticComponent<P> extends NamedExoticComponent<P> {
+        /**
+         * @deprecated Use {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#default_value|default values for destructuring assignments instead}.
+         */
         defaultProps?: Partial<P> | undefined;
         propTypes?: WeakValidationMap<P> | undefined;
     }
 
@@ -1558,9 +1602,9 @@
      * ));
      * ```
      */
     function forwardRef<T, P = {}>(
-        render: ForwardRefRenderFunction<T, P>,
+        render: ForwardRefRenderFunction<T, PropsWithoutRef<P>>,
     ): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;
 
     /**
      * Omits the 'ref' attribute from the given props object.
@@ -2087,8 +2131,23 @@
      * @param callback A _synchronous_ function which causes state updates that can be deferred.
      */
     export function startTransition(scope: TransitionFunction): void;
 
+    /**
+     * Wrap any code rendering and triggering updates to your components into `act()` calls.
+     *
+     * Ensures that the behavior in your tests matches what happens in the browser
+     * more closely by executing pending `useEffect`s before returning. This also
+     * reduces the amount of re-renders done.
+     *
+     * @param callback A synchronous, void callback that will execute as a single, complete React commit.
+     *
+     * @see https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks
+     */
+    // While act does always return Thenable, if a void function is passed, we pretend the return value is also void to not trigger dangling Promise lint rules.
+    export function act(callback: () => VoidOrUndefinedOnly): void;
+    export function act<T>(callback: () => T | Promise<T>): Promise<T>;
+
     export function useId(): string;
 
     /**
      * @param effect Imperative function that can return a cleanup function
@@ -2374,11 +2433,11 @@
 
         // Keyboard Events
         onKeyDown?: KeyboardEventHandler<T> | undefined;
         onKeyDownCapture?: KeyboardEventHandler<T> | undefined;
-        /** @deprecated */
+        /** @deprecated Use `onKeyUp` or `onKeyDown` instead */
         onKeyPress?: KeyboardEventHandler<T> | undefined;
-        /** @deprecated */
+        /** @deprecated Use `onKeyUpCapture` or `onKeyDownCapture` instead */
         onKeyPressCapture?: KeyboardEventHandler<T> | undefined;
         onKeyUp?: KeyboardEventHandler<T> | undefined;
         onKeyUpCapture?: KeyboardEventHandler<T> | undefined;
 
@@ -2845,8 +2904,9 @@
         contentEditable?: Booleanish | "inherit" | "plaintext-only" | undefined;
         contextMenu?: string | undefined;
         dir?: string | undefined;
         draggable?: Booleanish | undefined;
+        enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
         hidden?: boolean | undefined;
         id?: string | undefined;
         lang?: string | undefined;
         nonce?: string | undefined;
@@ -3300,9 +3360,8 @@
         autoComplete?: HTMLInputAutoCompleteAttribute | undefined;
         capture?: boolean | "user" | "environment" | undefined; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
         checked?: boolean | undefined;
         disabled?: boolean | undefined;
-        enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined;
         form?: string | undefined;
         formAction?:
             | string
             | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_EXPERIMENTAL_FORM_ACTIONS[