@types/react 17.0.33 → 17.0.37
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/experimental.d.ts +51 -9
- react/index.d.ts +4 -1
- react/next.d.ts +14 -73
- react/package.json +3 -3
react/README.md
CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for React (http://facebook.github.io/reac
|
|
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: Wed, 24 Nov 2021 21:01:04 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/experimental.d.ts
CHANGED
@@ -39,18 +39,60 @@ import React = require('./next');
|
|
39
39
|
export {};
|
40
40
|
|
41
41
|
declare module '.' {
|
42
|
+
export type SuspenseListRevealOrder = 'forwards' | 'backwards' | 'together';
|
43
|
+
export type SuspenseListTailMode = 'collapsed' | 'hidden';
|
44
|
+
|
45
|
+
export interface SuspenseListCommonProps {
|
46
|
+
/**
|
47
|
+
* Note that SuspenseList require more than one child;
|
48
|
+
* it is a runtime warning to provide only a single child.
|
49
|
+
*
|
50
|
+
* It does, however, allow those children to be wrapped inside a single
|
51
|
+
* level of `<React.Fragment>`.
|
52
|
+
*/
|
53
|
+
children: ReactElement | Iterable<ReactElement>;
|
54
|
+
}
|
55
|
+
|
56
|
+
interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
|
57
|
+
/**
|
58
|
+
* Defines the order in which the `SuspenseList` children should be revealed.
|
59
|
+
*/
|
60
|
+
revealOrder: 'forwards' | 'backwards';
|
61
|
+
/**
|
62
|
+
* Dictates how unloaded items in a SuspenseList is shown.
|
63
|
+
*
|
64
|
+
* - By default, `SuspenseList` will show all fallbacks in the list.
|
65
|
+
* - `collapsed` shows only the next fallback in the list.
|
66
|
+
* - `hidden` doesn’t show any unloaded items.
|
67
|
+
*/
|
68
|
+
tail?: SuspenseListTailMode | undefined;
|
69
|
+
}
|
70
|
+
|
71
|
+
interface NonDirectionalSuspenseListProps extends SuspenseListCommonProps {
|
72
|
+
/**
|
73
|
+
* Defines the order in which the `SuspenseList` children should be revealed.
|
74
|
+
*/
|
75
|
+
revealOrder?: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps['revealOrder']> | undefined;
|
76
|
+
/**
|
77
|
+
* The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
|
78
|
+
*/
|
79
|
+
tail?: never | undefined;
|
80
|
+
}
|
81
|
+
|
82
|
+
export type SuspenseListProps = DirectionalSuspenseListProps | NonDirectionalSuspenseListProps;
|
83
|
+
|
42
84
|
/**
|
43
|
-
*
|
44
|
-
*
|
85
|
+
* `SuspenseList` helps coordinate many components that can suspend by orchestrating the order
|
86
|
+
* in which these components are revealed to the user.
|
87
|
+
*
|
88
|
+
* When multiple components need to fetch data, this data may arrive in an unpredictable order.
|
89
|
+
* However, if you wrap these items in a `SuspenseList`, React will not show an item in the list
|
90
|
+
* until previous items have been displayed (this behavior is adjustable).
|
45
91
|
*
|
46
|
-
* @see https://
|
92
|
+
* @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist
|
93
|
+
* @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist
|
47
94
|
*/
|
48
|
-
|
49
|
-
export function unstable_useSyncExternalStore<Snapshot>(
|
50
|
-
subscribe: (onStoreChange: () => void) => () => void,
|
51
|
-
getSnapshot: () => Snapshot,
|
52
|
-
getServerSnapshot?: () => Snapshot,
|
53
|
-
): Snapshot;
|
95
|
+
export const SuspenseList: ExoticComponent<SuspenseListProps>;
|
54
96
|
|
55
97
|
/**
|
56
98
|
* @param effect Imperative function that can return a cleanup function
|
react/index.d.ts
CHANGED
@@ -395,9 +395,12 @@ declare namespace React {
|
|
395
395
|
interface SuspenseProps {
|
396
396
|
children?: ReactNode | undefined;
|
397
397
|
|
398
|
+
// TODO(react18): `fallback?: ReactNode;`
|
398
399
|
/** A fallback react tree to show when a Suspense child (like React.lazy) suspends */
|
399
400
|
fallback: NonNullable<ReactNode>|null;
|
400
401
|
}
|
402
|
+
|
403
|
+
// TODO(react18): Updated JSDoc to reflect that Suspense works on the server.
|
401
404
|
/**
|
402
405
|
* This feature is not yet available for server-side rendering.
|
403
406
|
* Suspense support will be added in a later release.
|
@@ -836,7 +839,7 @@ declare namespace React {
|
|
836
839
|
? JSX.IntrinsicElements[T]
|
837
840
|
: {};
|
838
841
|
type ComponentPropsWithRef<T extends ElementType> =
|
839
|
-
T extends
|
842
|
+
T extends (new (props: infer P) => Component<any, any>)
|
840
843
|
? PropsWithoutRef<P> & RefAttributes<InstanceType<T>>
|
841
844
|
: PropsWithRef<ComponentProps<T>>;
|
842
845
|
type ComponentPropsWithoutRef<T extends ElementType> =
|
react/next.d.ts
CHANGED
@@ -42,61 +42,6 @@ declare module '.' {
|
|
42
42
|
unstable_expectedLoadTime?: number | undefined;
|
43
43
|
}
|
44
44
|
|
45
|
-
export type SuspenseListRevealOrder = 'forwards' | 'backwards' | 'together';
|
46
|
-
export type SuspenseListTailMode = 'collapsed' | 'hidden';
|
47
|
-
|
48
|
-
export interface SuspenseListCommonProps {
|
49
|
-
/**
|
50
|
-
* Note that SuspenseList require more than one child;
|
51
|
-
* it is a runtime warning to provide only a single child.
|
52
|
-
*
|
53
|
-
* It does, however, allow those children to be wrapped inside a single
|
54
|
-
* level of `<React.Fragment>`.
|
55
|
-
*/
|
56
|
-
children: ReactElement | Iterable<ReactElement>;
|
57
|
-
}
|
58
|
-
|
59
|
-
interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
|
60
|
-
/**
|
61
|
-
* Defines the order in which the `SuspenseList` children should be revealed.
|
62
|
-
*/
|
63
|
-
revealOrder: 'forwards' | 'backwards';
|
64
|
-
/**
|
65
|
-
* Dictates how unloaded items in a SuspenseList is shown.
|
66
|
-
*
|
67
|
-
* - By default, `SuspenseList` will show all fallbacks in the list.
|
68
|
-
* - `collapsed` shows only the next fallback in the list.
|
69
|
-
* - `hidden` doesn’t show any unloaded items.
|
70
|
-
*/
|
71
|
-
tail?: SuspenseListTailMode | undefined;
|
72
|
-
}
|
73
|
-
|
74
|
-
interface NonDirectionalSuspenseListProps extends SuspenseListCommonProps {
|
75
|
-
/**
|
76
|
-
* Defines the order in which the `SuspenseList` children should be revealed.
|
77
|
-
*/
|
78
|
-
revealOrder?: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps['revealOrder']> | undefined;
|
79
|
-
/**
|
80
|
-
* The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
|
81
|
-
*/
|
82
|
-
tail?: never | undefined;
|
83
|
-
}
|
84
|
-
|
85
|
-
export type SuspenseListProps = DirectionalSuspenseListProps | NonDirectionalSuspenseListProps;
|
86
|
-
|
87
|
-
/**
|
88
|
-
* `SuspenseList` helps coordinate many components that can suspend by orchestrating the order
|
89
|
-
* in which these components are revealed to the user.
|
90
|
-
*
|
91
|
-
* When multiple components need to fetch data, this data may arrive in an unpredictable order.
|
92
|
-
* However, if you wrap these items in a `SuspenseList`, React will not show an item in the list
|
93
|
-
* until previous items have been displayed (this behavior is adjustable).
|
94
|
-
*
|
95
|
-
* @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist
|
96
|
-
* @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist
|
97
|
-
*/
|
98
|
-
export const SuspenseList: ExoticComponent<SuspenseListProps>;
|
99
|
-
|
100
45
|
// must be synchronous
|
101
46
|
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
102
47
|
// strange definition to allow vscode to show documentation on the invocation
|
@@ -151,24 +96,7 @@ declare module '.' {
|
|
151
96
|
*/
|
152
97
|
export function startTransition(scope: TransitionFunction): void;
|
153
98
|
|
154
|
-
|
155
|
-
/**
|
156
|
-
* WARNING: Don't use this as a `string`.
|
157
|
-
*
|
158
|
-
* This is an opaque type that is not supposed to type-check structurally.
|
159
|
-
* It is only valid if returned from React methods and passed to React e.g. `<button aria-labelledby={opaqueIdentifier} />`
|
160
|
-
*/
|
161
|
-
// We can't create a type that would be rejected for string concatenation or `.toString()` calls.
|
162
|
-
// So in order to not have to add `string | OpaqueIdentifier` to every react-dom host prop we intersect it with `string`.
|
163
|
-
type OpaqueIdentifier = string & {
|
164
|
-
readonly [opaqueIdentifierBranding]: unknown;
|
165
|
-
// While this would cause `const stringified: string = opaqueIdentifier.toString()` to not type-check it also adds completions while typing.
|
166
|
-
// It would also still allow string concatenation.
|
167
|
-
// Unsure which is better. Not type-checking or not suggesting.
|
168
|
-
// toString(): void;
|
169
|
-
};
|
170
|
-
|
171
|
-
export function unstable_useOpaqueIdentifier(): OpaqueIdentifier;
|
99
|
+
export function useId(): string;
|
172
100
|
|
173
101
|
/**
|
174
102
|
* this should be an internal type
|
@@ -196,4 +124,17 @@ declare module '.' {
|
|
196
124
|
* @see https://github.com/reactjs/rfcs/blob/master/text/0147-use-mutable-source.md
|
197
125
|
*/
|
198
126
|
export function unstable_useMutableSource<T, TResult extends unknown>(MutableSource: MutableSource<T>, getSnapshot: (source: T) => TResult, subscribe: MutableSourceSubscribe<T>): TResult;
|
127
|
+
|
128
|
+
/**
|
129
|
+
* @param subscribe
|
130
|
+
* @param getSnapshot
|
131
|
+
*
|
132
|
+
* @see https://github.com/reactwg/react-18/discussions/86
|
133
|
+
*/
|
134
|
+
// keep in sync with `useSyncExternalStore` from `use-sync-external-store`
|
135
|
+
export function useSyncExternalStore<Snapshot>(
|
136
|
+
subscribe: (onStoreChange: () => void) => () => void,
|
137
|
+
getSnapshot: () => Snapshot,
|
138
|
+
getServerSnapshot?: () => Snapshot,
|
139
|
+
): Snapshot;
|
199
140
|
}
|
react/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/react",
|
3
|
-
"version": "17.0.
|
3
|
+
"version": "17.0.37",
|
4
4
|
"description": "TypeScript definitions for React",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
|
6
6
|
"license": "MIT",
|
@@ -146,6 +146,6 @@
|
|
146
146
|
"@types/scheduler": "*",
|
147
147
|
"csstype": "^3.0.2"
|
148
148
|
},
|
149
|
-
"typesPublisherContentHash": "
|
150
|
-
"typeScriptVersion": "3.
|
149
|
+
"typesPublisherContentHash": "91aa69834e615fe0e64009b964243f620503bdaf0c74f0a35b07b7f35b0f8de4",
|
150
|
+
"typeScriptVersion": "3.8"
|
151
151
|
}
|