@types/react 18.2.40 → 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 +1 -1
- react/index.d.ts +14 -2
- react/package.json +2 -2
- react/ts5.0/index.d.ts +14 -2
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:
|
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
@@ -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<
|
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<
|
895
|
+
type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
|
884
896
|
readonly _result: T;
|
885
897
|
};
|
886
898
|
|
react/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react",
|
3
|
-
"version": "18.2.
|
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": "
|
204
|
+
"typesPublisherContentHash": "8505990e29e747f13b82dc62d59fcb677a12e2150527e5de599a9cc19e91a448",
|
205
205
|
"typeScriptVersion": "4.6"
|
206
206
|
}
|
react/ts5.0/index.d.ts
CHANGED
@@ -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<
|
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<
|
896
|
+
type LazyExoticComponent<T extends ComponentType<any>> = ExoticComponent<CustomComponentPropsWithRef<T>> & {
|
885
897
|
readonly _result: T;
|
886
898
|
};
|
887
899
|
|