@types/react 18.2.40 → 18.2.42

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: Fri, 01 Dec 2023 22:07:07 GMT
11
+ * Last updated: Mon, 04 Dec 2023 20:35:43 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
@@ -794,6 +794,9 @@ declare namespace React {
794
794
  UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
795
795
  }
796
796
 
797
+ /**
798
+ * @deprecated https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html
799
+ */
797
800
  interface Mixin<P, S> extends ComponentLifecycle<P, S> {
798
801
  mixins?: Array<Mixin<P, S>> | undefined;
799
802
  statics?: {
@@ -809,6 +812,9 @@ declare namespace React {
809
812
  getInitialState?(): S;
810
813
  }
811
814
 
815
+ /**
816
+ * @deprecated https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html
817
+ */
812
818
  interface ComponentSpec<P, S> extends Mixin<P, S> {
813
819
  render(): ReactNode;
814
820
 
@@ -854,9 +860,21 @@ declare namespace React {
854
860
  JSXElementConstructor<infer P> ? P
855
861
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
856
862
  : {};
863
+ /**
864
+ * Get the props of a component that supports the `ref` prop.
865
+ *
866
+ * WARNING: Use `CustomComponentPropsWithRef` if you know that `T` is not a host component for better type-checking performance.
867
+ */
857
868
  type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
858
869
  ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
859
870
  : PropsWithRef<ComponentProps<T>>;
871
+ /**
872
+ * Like `ComponentPropsWithRef` but without support for host components (i.e. just "custom components") to improve type-checking performance.
873
+ */
874
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
875
+ ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
876
+ : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
877
+ : never;
860
878
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
861
879
 
862
880
  type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
@@ -867,7 +885,7 @@ declare namespace React {
867
885
 
868
886
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
869
887
  // but can be given its own specific name
870
- type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<ComponentPropsWithRef<T>> & {
888
+ type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<CustomComponentPropsWithRef<T>> & {
871
889
  readonly type: T;
872
890
  };
873
891
 
@@ -880,7 +898,7 @@ declare namespace React {
880
898
  propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
881
899
  ): MemoExoticComponent<T>;
882
900
 
883
- type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
901
+ type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
884
902
  readonly _result: T;
885
903
  };
886
904
 
react/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "18.2.40",
3
+ "version": "18.2.42",
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": "c65bc742ac93777dbe6bf37221da607aa06982b098bc16250e645a4b7df2964a",
204
+ "typesPublisherContentHash": "d89c7ef8f0a7ec1f3081404a330d066b905c2554ae9b41deefa84b120269ebee",
205
205
  "typeScriptVersion": "4.6"
206
206
  }
react/ts5.0/index.d.ts CHANGED
@@ -795,6 +795,9 @@ declare namespace React {
795
795
  UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<S>, nextContext: any): void;
796
796
  }
797
797
 
798
+ /**
799
+ * @deprecated https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html
800
+ */
798
801
  interface Mixin<P, S> extends ComponentLifecycle<P, S> {
799
802
  mixins?: Array<Mixin<P, S>> | undefined;
800
803
  statics?: {
@@ -810,6 +813,9 @@ declare namespace React {
810
813
  getInitialState?(): S;
811
814
  }
812
815
 
816
+ /**
817
+ * @deprecated https://legacy.reactjs.org/blog/2016/07/13/mixins-considered-harmful.html
818
+ */
813
819
  interface ComponentSpec<P, S> extends Mixin<P, S> {
814
820
  render(): ReactNode;
815
821
 
@@ -855,9 +861,21 @@ declare namespace React {
855
861
  JSXElementConstructor<infer P> ? P
856
862
  : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T]
857
863
  : {};
864
+ /**
865
+ * Get the props of a component that supports the `ref` prop.
866
+ *
867
+ * WARNING: Use `CustomComponentPropsWithRef` if you know that `T` is not a host component for better type-checking performance.
868
+ */
858
869
  type ComponentPropsWithRef<T extends ElementType> = T extends (new(props: infer P) => Component<any, any>)
859
870
  ? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
860
871
  : PropsWithRef<ComponentProps<T>>;
872
+ /**
873
+ * Like `ComponentPropsWithRef` but without support for host components (i.e. just "custom components") to improve type-checking performance.
874
+ */
875
+ type CustomComponentPropsWithRef<T extends ComponentType> = T extends (new(props: infer P) => Component<any, any>)
876
+ ? (PropsWithoutRef<P> & RefAttributes<InstanceType<T>>)
877
+ : T extends ((props: infer P, legacyContext?: any) => ReactNode) ? PropsWithRef<P>
878
+ : never;
861
879
  type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<ComponentProps<T>>;
862
880
 
863
881
  type ComponentRef<T extends ElementType> = T extends NamedExoticComponent<
@@ -868,7 +886,7 @@ declare namespace React {
868
886
 
869
887
  // will show `Memo(${Component.displayName || Component.name})` in devtools by default,
870
888
  // but can be given its own specific name
871
- type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<ComponentPropsWithRef<T>> & {
889
+ type MemoExoticComponent<T extends ComponentType<any>> = NamedExoticComponent<CustomComponentPropsWithRef<T>> & {
872
890
  readonly type: T;
873
891
  };
874
892
 
@@ -881,7 +899,7 @@ declare namespace React {
881
899
  propsAreEqual?: (prevProps: Readonly<ComponentProps<T>>, nextProps: Readonly<ComponentProps<T>>) => boolean,
882
900
  ): MemoExoticComponent<T>;
883
901
 
884
- type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<ComponentPropsWithRef<T>> & {
902
+ type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
885
903
  readonly _result: T;
886
904
  };
887
905