@types/react 18.2.7 → 18.2.8
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 +21 -6
- react/jsx-dev-runtime.d.ts +1 -0
- react/jsx-runtime.d.ts +1 -0
- react/package.json +2 -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: Thu, 01 Jun 2023 19:32:50 GMT
|
12
12
|
* Dependencies: [@types/csstype](https://npmjs.com/package/@types/csstype), [@types/prop-types](https://npmjs.com/package/@types/prop-types), [@types/scheduler](https://npmjs.com/package/@types/scheduler)
|
13
13
|
* Global values: `React`
|
14
14
|
|
react/index.d.ts
CHANGED
@@ -82,7 +82,7 @@ declare namespace React {
|
|
82
82
|
* @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components
|
83
83
|
*/
|
84
84
|
deprecatedLegacyContext?: any,
|
85
|
-
) =>
|
85
|
+
) => ReactNode)
|
86
86
|
| (new (props: P) => Component<any, any>);
|
87
87
|
|
88
88
|
interface RefObject<T> {
|
@@ -113,7 +113,7 @@ declare namespace React {
|
|
113
113
|
C extends
|
114
114
|
| ForwardRefExoticComponent<any>
|
115
115
|
| { new (props: any): Component<any> }
|
116
|
-
| ((props: any, context?: any) =>
|
116
|
+
| ((props: any, context?: any) => ReactNode)
|
117
117
|
| keyof JSX.IntrinsicElements
|
118
118
|
> =
|
119
119
|
// need to check first if `ref` is a valid prop for ts@3.0
|
@@ -380,7 +380,7 @@ declare namespace React {
|
|
380
380
|
/**
|
381
381
|
* **NOTE**: Exotic components are not callable.
|
382
382
|
*/
|
383
|
-
(props: P):
|
383
|
+
(props: P): ReactNode;
|
384
384
|
readonly $$typeof: symbol;
|
385
385
|
}
|
386
386
|
|
@@ -550,7 +550,7 @@ declare namespace React {
|
|
550
550
|
type FC<P = {}> = FunctionComponent<P>;
|
551
551
|
|
552
552
|
interface FunctionComponent<P = {}> {
|
553
|
-
(props: P, context?: any):
|
553
|
+
(props: P, context?: any): ReactNode;
|
554
554
|
propTypes?: WeakValidationMap<P> | undefined;
|
555
555
|
contextTypes?: ValidationMap<any> | undefined;
|
556
556
|
defaultProps?: Partial<P> | undefined;
|
@@ -566,7 +566,7 @@ declare namespace React {
|
|
566
566
|
* @deprecated - Equivalent with `React.FunctionComponent`.
|
567
567
|
*/
|
568
568
|
interface VoidFunctionComponent<P = {}> {
|
569
|
-
(props: P, context?: any):
|
569
|
+
(props: P, context?: any): ReactNode;
|
570
570
|
propTypes?: WeakValidationMap<P> | undefined;
|
571
571
|
contextTypes?: ValidationMap<any> | undefined;
|
572
572
|
defaultProps?: Partial<P> | undefined;
|
@@ -576,7 +576,7 @@ declare namespace React {
|
|
576
576
|
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
577
577
|
|
578
578
|
interface ForwardRefRenderFunction<T, P = {}> {
|
579
|
-
(props: P, ref: ForwardedRef<T>):
|
579
|
+
(props: P, ref: ForwardedRef<T>): ReactNode;
|
580
580
|
displayName?: string | undefined;
|
581
581
|
// explicit rejected with `never` required due to
|
582
582
|
// https://github.com/microsoft/TypeScript/issues/36826
|
@@ -3125,7 +3125,9 @@ declare namespace React {
|
|
3125
3125
|
componentStack: string;
|
3126
3126
|
}
|
3127
3127
|
|
3128
|
+
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
3128
3129
|
namespace JSX {
|
3130
|
+
type ElementType = GlobalJSXElementType;
|
3129
3131
|
interface Element extends GlobalJSXElement {}
|
3130
3132
|
interface ElementClass extends GlobalJSXElementClass {}
|
3131
3133
|
interface ElementAttributesProperty extends GlobalJSXElementAttributesProperty {}
|
@@ -3188,6 +3190,18 @@ declare global {
|
|
3188
3190
|
* @deprecated Use `React.JSX` instead of the global `JSX` namespace.
|
3189
3191
|
*/
|
3190
3192
|
namespace JSX {
|
3193
|
+
// We don't just alias React.ElementType because React.ElementType
|
3194
|
+
// historically does more than we need it to.
|
3195
|
+
// E.g. it also contains .propTypes and so TS also verifies the declared
|
3196
|
+
// props type does match the declared .propTypes.
|
3197
|
+
// But if libraries declared their .propTypes but not props type,
|
3198
|
+
// or they mismatch, you won't be able to use the class component
|
3199
|
+
// as a JSX.ElementType.
|
3200
|
+
// We could fix this everywhere but we're ultimately not interested in
|
3201
|
+
// .propTypes assignability so we might as well drop it entirely here to
|
3202
|
+
// reduce the work of the type-checker.
|
3203
|
+
// TODO: Check impact of making React.ElementType<P = any> = React.JSXElementConstructor<P>
|
3204
|
+
type ElementType = string | React.JSXElementConstructor<any>;
|
3191
3205
|
interface Element extends React.ReactElement<any, any> { }
|
3192
3206
|
interface ElementClass extends React.Component<any> {
|
3193
3207
|
render(): React.ReactNode;
|
@@ -3394,6 +3408,7 @@ declare global {
|
|
3394
3408
|
// React.JSX needs to point to global.JSX to keep global module augmentations intact.
|
3395
3409
|
// But we can't access global.JSX so we need to create these aliases instead.
|
3396
3410
|
// Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
|
3411
|
+
type GlobalJSXElementType = JSX.ElementType;
|
3397
3412
|
interface GlobalJSXElement extends JSX.Element {}
|
3398
3413
|
interface GlobalJSXElementClass extends JSX.ElementClass {}
|
3399
3414
|
interface GlobalJSXElementAttributesProperty extends JSX.ElementAttributesProperty {}
|
react/jsx-dev-runtime.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from './';
|
2
2
|
|
3
3
|
export namespace JSX {
|
4
|
+
type ElementType = React.JSX.ElementType;
|
4
5
|
interface Element extends React.JSX.Element {}
|
5
6
|
interface ElementClass extends React.JSX.ElementClass {}
|
6
7
|
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {}
|
react/jsx-runtime.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from './';
|
2
2
|
|
3
3
|
export namespace JSX {
|
4
|
+
type ElementType = React.JSX.ElementType;
|
4
5
|
interface Element extends React.JSX.Element {}
|
5
6
|
interface ElementClass extends React.JSX.ElementClass {}
|
6
7
|
interface ElementAttributesProperty extends React.JSX.ElementAttributesProperty {}
|
react/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react",
|
3
|
-
"version": "18.2.
|
3
|
+
"version": "18.2.8",
|
4
4
|
"description": "TypeScript definitions for React",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
|
6
6
|
"license": "MIT",
|
@@ -158,7 +158,7 @@
|
|
158
158
|
"@types/scheduler": "*",
|
159
159
|
"csstype": "^3.0.2"
|
160
160
|
},
|
161
|
-
"typesPublisherContentHash": "
|
161
|
+
"typesPublisherContentHash": "faad15770912a82e3d230f36a11f9d053561dc55fea87ada2a3c00a6b758a215",
|
162
162
|
"typeScriptVersion": "4.3",
|
163
163
|
"exports": {
|
164
164
|
".": {
|