@types/react 18.2.38 → 18.2.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
react/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for react (https://react.dev/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Mon, 20 Nov 2023 23:36:24 GMT
11
+ * Last updated: Sat, 02 Dec 2023 17:07:00 GMT
12
12
  * Dependencies: [@types/prop-types](https://npmjs.com/package/@types/prop-types), [@types/scheduler](https://npmjs.com/package/@types/scheduler), [csstype](https://npmjs.com/package/csstype)
13
13
 
14
14
  # Credits
react/index.d.ts CHANGED
@@ -452,7 +452,7 @@ declare namespace React {
452
452
  */
453
453
  type ProfilerOnRenderCallback = (
454
454
  id: string,
455
- phase: "mount" | "update",
455
+ phase: "mount" | "update" | "nested-update",
456
456
  actualDuration: number,
457
457
  baseDuration: number,
458
458
  startTime: number,
@@ -854,9 +854,21 @@ declare namespace React {
854
854
  JSXElementConstructor<infer P> ? P
855
855
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
856
856
  : {};
857
+ /**
858
+ * Get the props of a component that supports the `ref` prop.
859
+ *
860
+ * WARNING: Use `CustomComponentPropsWithRef` if you know that `T` is not a host component for better type-checking performance.
861
+ */
857
862
  type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
858
863
  ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
859
864
  : PropsWithRef<ComponentProps<T>>;
865
+ /**
866
+ * Like `ComponentPropsWithRef` but without support for host components (i.e. just "custom components") to improve type-checking performance.
867
+ */
868
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
869
+ ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
870
+ : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
871
+ : never;
860
872
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
861
873
 
862
874
  type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
@@ -867,7 +879,7 @@ declare namespace React {
867
879
 
868
880
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
869
881
  // but can be given its own specific name
870
- type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<ComponentPropsWithRef<T>> & {
882
+ type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<CustomComponentPropsWithRef<T>> & {
871
883
  readonly type: T;
872
884
  };
873
885
 
@@ -880,7 +892,7 @@ declare namespace React {
880
892
  propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
881
893
  ): MemoExoticComponent<T>;
882
894
 
883
- type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
895
+ type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
884
896
  readonly _result: T;
885
897
  };
886
898
 
@@ -1130,7 +1142,7 @@ declare namespace React {
1130
1142
  * @see https://react.dev/reference/react/useMemo
1131
1143
  */
1132
1144
  // allow undefined, but don't make it optional as that is very likely a mistake
1133
- function useMemo<T>(factory: () => T, deps: DependencyList | undefined): T;
1145
+ function useMemo<T>(factory: () => T, deps: DependencyList): T;
1134
1146
  /**
1135
1147
  * `useDebugValue` can be used to display a label for custom hooks in React DevTools.
1136
1148
  *
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "18.2.38",
3
+ "version": "18.2.41",
4
4
  "description": "TypeScript definitions for react",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
6
6
  "license": "MIT",
@@ -201,6 +201,6 @@
201
201
  "@types/scheduler": "*",
202
202
  "csstype": "^3.0.2"
203
203
  },
204
- "typesPublisherContentHash": "a38e95dab4d1c8518f0386413ce2b6bb745f253e6dee2614c413d2b0ac9f804c",
205
- "typeScriptVersion": "4.5"
204
+ "typesPublisherContentHash": "8505990e29e747f13b82dc62d59fcb677a12e2150527e5de599a9cc19e91a448",
205
+ "typeScriptVersion": "4.6"
206
206
  }
react/ts5.0/index.d.ts CHANGED
@@ -453,7 +453,7 @@ declare namespace React {
453
453
  */
454
454
  type ProfilerOnRenderCallback = (
455
455
  id: string,
456
- phase: "mount" | "update",
456
+ phase: "mount" | "update" | "nested-update",
457
457
  actualDuration: number,
458
458
  baseDuration: number,
459
459
  startTime: number,
@@ -855,9 +855,21 @@ declare namespace React {
855
855
  JSXElementConstructor<infer P> ? P
856
856
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
857
857
  : {};
858
+ /**
859
+ * Get the props of a component that supports the `ref` prop.
860
+ *
861
+ * WARNING: Use `CustomComponentPropsWithRef` if you know that `T` is not a host component for better type-checking performance.
862
+ */
858
863
  type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
859
864
  ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
860
865
  : PropsWithRef<ComponentProps<T>>;
866
+ /**
867
+ * Like `ComponentPropsWithRef` but without support for host components (i.e. just "custom components") to improve type-checking performance.
868
+ */
869
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
870
+ ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
871
+ : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
872
+ : never;
861
873
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
862
874
 
863
875
  type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
@@ -868,7 +880,7 @@ declare namespace React {
868
880
 
869
881
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
870
882
  // but can be given its own specific name
871
- type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<ComponentPropsWithRef<T>> & {
883
+ type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<CustomComponentPropsWithRef<T>> & {
872
884
  readonly type: T;
873
885
  };
874
886
 
@@ -881,7 +893,7 @@ declare namespace React {
881
893
  propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
882
894
  ): MemoExoticComponent<T>;
883
895
 
884
- type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
896
+ type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
885
897
  readonly _result: T;
886
898
  };
887
899
 
@@ -1131,7 +1143,7 @@ declare namespace React {
1131
1143
  * @see https://react.dev/reference/react/useMemo
1132
1144
  */
1133
1145
  // allow undefined, but don't make it optional as that is very likely a mistake
1134
- function useMemo<T>(factory: () => T, deps: DependencyList | undefined): T;
1146
+ function useMemo<T>(factory: () => T, deps: DependencyList): T;
1135
1147
  /**
1136
1148
  * `useDebugValue` can be used to display a label for custom hooks in React DevTools.
1137
1149
  *