@types/react 18.2.6 → 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 +27 -6
- react/jsx-dev-runtime.d.ts +1 -0
- react/jsx-runtime.d.ts +1 -0
- react/package.json +2 -2
- react/ts5.0/index.d.ts +7 -1
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
@@ -76,7 +76,13 @@ declare namespace React {
|
|
76
76
|
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
77
77
|
|
78
78
|
type JSXElementConstructor<P> =
|
79
|
-
| ((
|
79
|
+
| ((
|
80
|
+
props: P,
|
81
|
+
/**
|
82
|
+
* @deprecated https://legacy.reactjs.org/docs/legacy-context.html#referencing-context-in-stateless-function-components
|
83
|
+
*/
|
84
|
+
deprecatedLegacyContext?: any,
|
85
|
+
) => ReactNode)
|
80
86
|
| (new (props: P) => Component<any, any>);
|
81
87
|
|
82
88
|
interface RefObject<T> {
|
@@ -107,7 +113,7 @@ declare namespace React {
|
|
107
113
|
C extends
|
108
114
|
| ForwardRefExoticComponent<any>
|
109
115
|
| { new (props: any): Component<any> }
|
110
|
-
| ((props: any, context?: any) =>
|
116
|
+
| ((props: any, context?: any) => ReactNode)
|
111
117
|
| keyof JSX.IntrinsicElements
|
112
118
|
> =
|
113
119
|
// need to check first if `ref` is a valid prop for ts@3.0
|
@@ -374,7 +380,7 @@ declare namespace React {
|
|
374
380
|
/**
|
375
381
|
* **NOTE**: Exotic components are not callable.
|
376
382
|
*/
|
377
|
-
(props: P):
|
383
|
+
(props: P): ReactNode;
|
378
384
|
readonly $$typeof: symbol;
|
379
385
|
}
|
380
386
|
|
@@ -544,7 +550,7 @@ declare namespace React {
|
|
544
550
|
type FC<P = {}> = FunctionComponent<P>;
|
545
551
|
|
546
552
|
interface FunctionComponent<P = {}> {
|
547
|
-
(props: P, context?: any):
|
553
|
+
(props: P, context?: any): ReactNode;
|
548
554
|
propTypes?: WeakValidationMap<P> | undefined;
|
549
555
|
contextTypes?: ValidationMap<any> | undefined;
|
550
556
|
defaultProps?: Partial<P> | undefined;
|
@@ -560,7 +566,7 @@ declare namespace React {
|
|
560
566
|
* @deprecated - Equivalent with `React.FunctionComponent`.
|
561
567
|
*/
|
562
568
|
interface VoidFunctionComponent<P = {}> {
|
563
|
-
(props: P, context?: any):
|
569
|
+
(props: P, context?: any): ReactNode;
|
564
570
|
propTypes?: WeakValidationMap<P> | undefined;
|
565
571
|
contextTypes?: ValidationMap<any> | undefined;
|
566
572
|
defaultProps?: Partial<P> | undefined;
|
@@ -570,7 +576,7 @@ declare namespace React {
|
|
570
576
|
type ForwardedRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null;
|
571
577
|
|
572
578
|
interface ForwardRefRenderFunction<T, P = {}> {
|
573
|
-
(props: P, ref: ForwardedRef<T>):
|
579
|
+
(props: P, ref: ForwardedRef<T>): ReactNode;
|
574
580
|
displayName?: string | undefined;
|
575
581
|
// explicit rejected with `never` required due to
|
576
582
|
// https://github.com/microsoft/TypeScript/issues/36826
|
@@ -3119,7 +3125,9 @@ declare namespace React {
|
|
3119
3125
|
componentStack: string;
|
3120
3126
|
}
|
3121
3127
|
|
3128
|
+
// Keep in sync with JSX namespace in ./jsx-runtime.d.ts and ./jsx-dev-runtime.d.ts
|
3122
3129
|
namespace JSX {
|
3130
|
+
type ElementType = GlobalJSXElementType;
|
3123
3131
|
interface Element extends GlobalJSXElement {}
|
3124
3132
|
interface ElementClass extends GlobalJSXElementClass {}
|
3125
3133
|
interface ElementAttributesProperty extends GlobalJSXElementAttributesProperty {}
|
@@ -3182,6 +3190,18 @@ declare global {
|
|
3182
3190
|
* @deprecated Use `React.JSX` instead of the global `JSX` namespace.
|
3183
3191
|
*/
|
3184
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>;
|
3185
3205
|
interface Element extends React.ReactElement<any, any> { }
|
3186
3206
|
interface ElementClass extends React.Component<any> {
|
3187
3207
|
render(): React.ReactNode;
|
@@ -3388,6 +3408,7 @@ declare global {
|
|
3388
3408
|
// React.JSX needs to point to global.JSX to keep global module augmentations intact.
|
3389
3409
|
// But we can't access global.JSX so we need to create these aliases instead.
|
3390
3410
|
// Once the global JSX namespace will be removed we replace React.JSX with the contents of global.JSX
|
3411
|
+
type GlobalJSXElementType = JSX.ElementType;
|
3391
3412
|
interface GlobalJSXElement extends JSX.Element {}
|
3392
3413
|
interface GlobalJSXElementClass extends JSX.ElementClass {}
|
3393
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
|
".": {
|
react/ts5.0/index.d.ts
CHANGED
@@ -44,7 +44,13 @@ declare namespace React {
|
|
44
44
|
type ComponentType<P = {}> = ComponentClass<P> | FunctionComponent<P>;
|
45
45
|
|
46
46
|
type JSXElementConstructor<P> =
|
47
|
-
| ((
|
47
|
+
| ((
|
48
|
+
props: P,
|
49
|
+
/**
|
50
|
+
* @deprecated https://legacy.react/ts5.0js.org/docs/legacy-context.html#referencing-context-in-stateless-function-components
|
51
|
+
*/
|
52
|
+
deprecatedLegacyContext?: any,
|
53
|
+
) => ReactElement<any, any> | null)
|
48
54
|
| (new (props: P) => Component<any, any>);
|
49
55
|
|
50
56
|
interface RefObject<T> {
|