npm package diff
Package: @types/react
Versions: 18.2.73 - 18.3.8
File: react/ts5.0/index.d.ts
Index: react/ts5.0/index.d.ts
===================================================================
--- react/ts5.0/index.d.ts
+++ react/ts5.0/index.d.ts
@@ -221,9 +221,9 @@
type ElementRef<
C extends
| ForwardRefExoticComponent<any>
| { new(props: any): Component<any> }
- | ((props: any, context?: any) => ReactElement | null)
+ | ((props: any, deprecatedLegacyContext?: any) => ReactElement | null)
| keyof JSX.IntrinsicElements,
> =
// need to check first if `ref` is a valid prop for [email protected]
// otherwise it will infer `{}` instead of `never`
@@ -493,23 +493,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"
@@ -842,8 +848,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.
@@ -1105,9 +1117,17 @@
* }
* ```
*/
interface FunctionComponent<P = {}> {
- (props: P, context?: any): ReactElement<any, any> | null;
+ (
+ props: P,
+ /**
+ * @deprecated
+ *
+ * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
+ */
+ deprecatedLegacyContext?: any,
+ ): ReactElement<any, any> | null;
/**
* Used to declare the types of the props accepted by the
* component. These types will be checked during rendering
* and in development only.
@@ -1145,8 +1165,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
@@ -1182,11 +1204,22 @@
*
* @see {@link React.FunctionComponent}
*/
interface VoidFunctionComponent<P = {}> {
- (props: P, context?: any): ReactElement<any, any> | null;
+ (
+ props: P,
+ /**
+ * @deprecated
+ *
+ * @see {@link https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-lifecycle-methods React Docs}
+ */
+ deprecatedLegacyContext?: any,
+ ): ReactElement<any, any> | null;
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;
}
@@ -1245,9 +1278,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.
@@ -1297,9 +1338,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;
}
/**
@@ -1312,9 +1353,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
// ----------------------------------------------------------------------
@@ -1527,8 +1568,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;
}
@@ -1559,9 +1603,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.
@@ -2088,8 +2132,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
@@ -2375,11 +2434,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;
@@ -2846,8 +2905,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;
@@ -3301,9 +3361,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[