@types/react 17.0.7 → 17.0.11

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 (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: Tue, 25 May 2021 12:31:21 GMT
11
+ * Last updated: Wed, 09 Jun 2021 14:01:27 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
@@ -34,148 +34,8 @@
34
34
  //
35
35
  // Suspense-related handling can be found in ReactFiberThrow.js.
36
36
 
37
- import React = require('.');
37
+ import React = require('./next');
38
38
 
39
39
  export {};
40
40
 
41
- declare const UNDEFINED_VOID_ONLY: unique symbol;
42
- type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
43
-
44
- declare module '.' {
45
- export interface SuspenseProps {
46
- /**
47
- * The presence of this prop indicates that the content is computationally expensive to render.
48
- * In other words, the tree is CPU bound and not I/O bound (e.g. due to fetching data).
49
- * @see {@link https://github.com/facebook/react/pull/19936}
50
- */
51
- unstable_expectedLoadTime?: number;
52
- }
53
-
54
- export type SuspenseListRevealOrder = 'forwards' | 'backwards' | 'together';
55
- export type SuspenseListTailMode = 'collapsed' | 'hidden';
56
-
57
- export interface SuspenseListCommonProps {
58
- /**
59
- * Note that SuspenseList require more than one child;
60
- * it is a runtime warning to provide only a single child.
61
- *
62
- * It does, however, allow those children to be wrapped inside a single
63
- * level of `<React.Fragment>`.
64
- */
65
- children: ReactElement | Iterable<ReactElement>;
66
- }
67
-
68
- interface DirectionalSuspenseListProps extends SuspenseListCommonProps {
69
- /**
70
- * Defines the order in which the `SuspenseList` children should be revealed.
71
- */
72
- revealOrder: 'forwards' | 'backwards';
73
- /**
74
- * Dictates how unloaded items in a SuspenseList is shown.
75
- *
76
- * - By default, `SuspenseList` will show all fallbacks in the list.
77
- * - `collapsed` shows only the next fallback in the list.
78
- * - `hidden` doesn’t show any unloaded items.
79
- */
80
- tail?: SuspenseListTailMode;
81
- }
82
-
83
- interface NonDirectionalSuspenseListProps extends SuspenseListCommonProps {
84
- /**
85
- * Defines the order in which the `SuspenseList` children should be revealed.
86
- */
87
- revealOrder?: Exclude<SuspenseListRevealOrder, DirectionalSuspenseListProps['revealOrder']>;
88
- /**
89
- * The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
90
- */
91
- tail?: never;
92
- }
93
-
94
- export type SuspenseListProps = DirectionalSuspenseListProps | NonDirectionalSuspenseListProps;
95
-
96
- /**
97
- * `SuspenseList` helps coordinate many components that can suspend by orchestrating the order
98
- * in which these components are revealed to the user.
99
- *
100
- * When multiple components need to fetch data, this data may arrive in an unpredictable order.
101
- * However, if you wrap these items in a `SuspenseList`, React will not show an item in the list
102
- * until previous items have been displayed (this behavior is adjustable).
103
- *
104
- * @see https://reactjs.org/docs/concurrent-mode-reference.html#suspenselist
105
- * @see https://reactjs.org/docs/concurrent-mode-patterns.html#suspenselist
106
- */
107
- export const unstable_SuspenseList: ExoticComponent<SuspenseListProps>;
108
-
109
- // must be synchronous
110
- export type TransitionFunction = () => VoidOrUndefinedOnly;
111
- // strange definition to allow vscode to show documentation on the invocation
112
- export interface TransitionStartFunction {
113
- /**
114
- * State updates caused inside the callback are allowed to be deferred.
115
- *
116
- * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
117
- *
118
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
119
- */
120
- (callback: TransitionFunction): void;
121
- }
122
-
123
- /**
124
- * Returns a deferred version of the value that may “lag behind” it for at most `timeoutMs`.
125
- *
126
- * This is commonly used to keep the interface responsive when you have something that renders immediately
127
- * based on user input and something that needs to wait for a data fetch.
128
- *
129
- * A good example of this is a text input.
130
- *
131
- * @param value The value that is going to be deferred
132
- *
133
- * @see https://reactjs.org/docs/concurrent-mode-reference.html#usedeferredvalue
134
- */
135
- export function unstable_useDeferredValue<T>(value: T): T;
136
-
137
- /**
138
- * Allows components to avoid undesirable loading states by waiting for content to load
139
- * before transitioning to the next screen. It also allows components to defer slower,
140
- * data fetching updates until subsequent renders so that more crucial updates can be
141
- * rendered immediately.
142
- *
143
- * The `useTransition` hook returns two values in an array.
144
- *
145
- * The first is boolean, React’s way of informing us whether we’re waiting for the transition to finish.
146
- * The seconda is a function that takes a callback. We can use it to tell React which state we want to defer.
147
- *
148
- * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
149
- *
150
- * @param config An optional object with `timeoutMs`
151
- *
152
- * @see https://reactjs.org/docs/concurrent-mode-reference.html#usetransition
153
- */
154
- export function unstable_useTransition(): [boolean, TransitionStartFunction];
155
-
156
- const opaqueIdentifierBranding: unique symbol;
157
- /**
158
- * WARNING: Don't use this as a `string`.
159
- *
160
- * This is an opaque type that is not supposed to type-check structurally.
161
- * It is only valid if returned from React methods and passed to React e.g. `<button aria-labelledby={opaqueIdentifier} />`
162
- */
163
- // We can't create a type that would be rejected for string concatenation or `.toString()` calls.
164
- // So in order to not have to add `string | OpaqueIdentifier` to every react-dom host prop we intersect it with `string`.
165
- type OpaqueIdentifier = string & {
166
- readonly [opaqueIdentifierBranding]: unknown;
167
- // While this would cause `const stringified: string = opaqueIdentifier.toString()` to not type-check it also adds completions while typing.
168
- // It would also still allow string concatenation.
169
- // Unsure which is better. Not type-checking or not suggesting.
170
- // toString(): void;
171
- };
172
-
173
- export function unstable_useOpaqueIdentifier(): OpaqueIdentifier;
174
-
175
- /**
176
- * Similar to `useTransition` but allows uses where hooks are not available.
177
- *
178
- * @param callback A _synchronous_ function which causes state updates that can be deferred.
179
- */
180
- export function unstable_startTransition(scope: TransitionFunction): void;
181
- }
41
+ declare module '.' {}
react/index.d.ts CHANGED
@@ -30,6 +30,10 @@
30
30
  // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
31
31
  // TypeScript Version: 2.8
32
32
 
33
+ // NOTE: Users of the upcoming React 18 release should add a reference
34
+ // to 'react/next' in their project. See next.d.ts's top comment
35
+ // for reference and documentation on how exactly to do it.
36
+
33
37
  // NOTE: Users of the `experimental` builds of React should add a reference
34
38
  // to 'react/experimental' in their project. See experimental.d.ts's top comment
35
39
  // for reference and documentation on how exactly to do it.
@@ -1019,7 +1023,6 @@ declare namespace React {
1019
1023
  * @version 16.8.0
1020
1024
  * @see https://reactjs.org/docs/hooks-reference.html#useref
1021
1025
  */
1022
- // TODO (TypeScript 3.0): <T extends unknown>
1023
1026
  function useRef<T>(initialValue: T): MutableRefObject<T>;
1024
1027
  // convenience overload for refs given as a ref prop as they typically start with a null value
1025
1028
  /**
@@ -1035,7 +1038,6 @@ declare namespace React {
1035
1038
  * @version 16.8.0
1036
1039
  * @see https://reactjs.org/docs/hooks-reference.html#useref
1037
1040
  */
1038
- // TODO (TypeScript 3.0): <T extends unknown>
1039
1041
  function useRef<T>(initialValue: T|null): RefObject<T>;
1040
1042
  // convenience overload for potentially undefined initialValue / call with 0 arguments
1041
1043
  // has a default to stop it from defaulting to {} instead
@@ -1049,7 +1051,6 @@ declare namespace React {
1049
1051
  * @version 16.8.0
1050
1052
  * @see https://reactjs.org/docs/hooks-reference.html#useref
1051
1053
  */
1052
- // TODO (TypeScript 3.0): <T extends unknown>
1053
1054
  function useRef<T = undefined>(): MutableRefObject<T | undefined>;
1054
1055
  /**
1055
1056
  * The signature is identical to `useEffect`, but it fires synchronously after all DOM mutations.
react/next.d.ts ADDED
@@ -0,0 +1,199 @@
1
+ /**
2
+ * These are types for things that are present in the upcoming React 18 release.
3
+ *
4
+ * Once React 18 is released they can just be moved to the main index file.
5
+ *
6
+ * To load the types declared here in an actual project, there are three ways. The easiest one,
7
+ * if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
8
+ * is to add `"react/next"` to the `"types"` array.
9
+ *
10
+ * Alternatively, a specific import syntax can to be used from a typescript file.
11
+ * This module does not exist in reality, which is why the {} is important:
12
+ *
13
+ * ```ts
14
+ * import {} from 'react/next'
15
+ * ```
16
+ *
17
+ * It is also possible to include it through a triple-slash reference:
18
+ *
19
+ * ```ts
20
+ * /// <reference types="react/next" />
21
+ * ```
22
+ *
23
+ * Either the import or the reference only needs to appear once, anywhere in the project.
24
+ */
25
+
26
+ // See https://github.com/facebook/react/blob/master/packages/react/src/React.js to see how the exports are declared,
27
+
28
+ import React = require('.');
29
+
30
+ export {};
31
+
32
+ declare const UNDEFINED_VOID_ONLY: unique symbol;
33
+ type VoidOrUndefinedOnly = void | { [UNDEFINED_VOID_ONLY]: never };
34
+
35
+ declare module '.' {
36
+ export interface SuspenseProps {
37
+ /**
38
+ * The presence of this prop indicates that the content is computationally expensive to render.
39
+ * In other words, the tree is CPU bound and not I/O bound (e.g. due to fetching data).
40
+ * @see {@link https://github.com/facebook/react/pull/19936}
41
+ */
42
+ unstable_expectedLoadTime?: number;
43
+ }
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;
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']>;
79
+ /**
80
+ * The tail property is invalid when not using the `forwards` or `backwards` reveal orders.
81
+ */
82
+ tail?: never;
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
+ // must be synchronous
101
+ export type TransitionFunction = () => VoidOrUndefinedOnly;
102
+ // strange definition to allow vscode to show documentation on the invocation
103
+ export interface TransitionStartFunction {
104
+ /**
105
+ * State updates caused inside the callback are allowed to be deferred.
106
+ *
107
+ * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
108
+ *
109
+ * @param callback A _synchronous_ function which causes state updates that can be deferred.
110
+ */
111
+ (callback: TransitionFunction): void;
112
+ }
113
+
114
+ /**
115
+ * Returns a deferred version of the value that may “lag behind” it for at most `timeoutMs`.
116
+ *
117
+ * This is commonly used to keep the interface responsive when you have something that renders immediately
118
+ * based on user input and something that needs to wait for a data fetch.
119
+ *
120
+ * A good example of this is a text input.
121
+ *
122
+ * @param value The value that is going to be deferred
123
+ *
124
+ * @see https://reactjs.org/docs/concurrent-mode-reference.html#usedeferredvalue
125
+ */
126
+ export function useDeferredValue<T>(value: T): T;
127
+
128
+ /**
129
+ * Allows components to avoid undesirable loading states by waiting for content to load
130
+ * before transitioning to the next screen. It also allows components to defer slower,
131
+ * data fetching updates until subsequent renders so that more crucial updates can be
132
+ * rendered immediately.
133
+ *
134
+ * The `useTransition` hook returns two values in an array.
135
+ *
136
+ * The first is boolean, React’s way of informing us whether we’re waiting for the transition to finish.
137
+ * The seconda is a function that takes a callback. We can use it to tell React which state we want to defer.
138
+ *
139
+ * **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
140
+ *
141
+ * @param config An optional object with `timeoutMs`
142
+ *
143
+ * @see https://reactjs.org/docs/concurrent-mode-reference.html#usetransition
144
+ */
145
+ export function useTransition(): [boolean, TransitionStartFunction];
146
+
147
+ /**
148
+ * Similar to `useTransition` but allows uses where hooks are not available.
149
+ *
150
+ * @param callback A _synchronous_ function which causes state updates that can be deferred.
151
+ */
152
+ export function startTransition(scope: TransitionFunction): void;
153
+
154
+ const opaqueIdentifierBranding: unique symbol;
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;
172
+
173
+ /**
174
+ * this should be an internal type
175
+ */
176
+ interface MutableSource<T> {
177
+ _source: T;
178
+ }
179
+
180
+ export type MutableSourceSubscribe<T> = (source: T, callback: () => void) => () => void;
181
+
182
+ /**
183
+ * @param source A source could be anything as long as they can be subscribed to and have a "version".
184
+ * @param getVersion A function returns a value which will change whenever part of the source changes.
185
+ */
186
+ export function unstable_createMutableSource<T>(source: T, getVersion: () => any): MutableSource<T>;
187
+
188
+ /**
189
+ * useMutableSource() enables React components to safely and efficiently read from a mutable external source in Concurrent Mode.
190
+ * The API will detect mutations that occur during a render to avoid tearing
191
+ * and it will automatically schedule updates when the source is mutated.
192
+ * @param MutableSource
193
+ * @param getSnapshot
194
+ * @param subscribe
195
+ *
196
+ * @see https://github.com/reactjs/rfcs/blob/master/text/0147-use-mutable-source.md
197
+ */
198
+ export function unstable_useMutableSource<T, TResult extends unknown>(MutableSource: MutableSource<T>, getSnapshot: (source: T) => TResult, subscribe: MutableSourceSubscribe<T>): TResult;
199
+ }
react/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@types/react",
3
- "version": "17.0.7",
3
+ "version": "17.0.11",
4
4
  "description": "TypeScript definitions for React",
5
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react",
5
6
  "license": "MIT",
6
7
  "contributors": [
7
8
  {
@@ -150,6 +151,6 @@
150
151
  "@types/scheduler": "*",
151
152
  "csstype": "^3.0.2"
152
153
  },
153
- "typesPublisherContentHash": "53fa0ca6f95f43ca1d6bb65289b682d451af9b827f566f06b37ba765cd69cd50",
154
- "typeScriptVersion": "3.5"
154
+ "typesPublisherContentHash": "c77392134576d6e26ea1cf5757ae9bb18e415173effa960387c647125921ac6b",
155
+ "typeScriptVersion": "3.6"
155
156
  }