@types/react 16.14.21 → 17.0.3
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 v16.14 → react}/LICENSE +0 -0
- react/README.md +16 -0
- react/experimental.d.ts +192 -0
- {react v16.14 → react}/global.d.ts +0 -0
- react v16.14/index.d.ts → react/index.d.ts +969 -1087
- {react v16.14 → react}/jsx-dev-runtime.d.ts +0 -0
- {react v16.14 → react}/jsx-runtime.d.ts +0 -0
- react v16.14/package.json → react/package.json +8 -9
- react v16.14/README.md +0 -16
{react v16.14 → react}/LICENSE
RENAMED
File without changes
|
react/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Installation
|
2
|
+
> `npm install --save @types/react`
|
3
|
+
|
4
|
+
# Summary
|
5
|
+
This package contains type definitions for React (http://facebook.github.io/react/).
|
6
|
+
|
7
|
+
# Details
|
8
|
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react.
|
9
|
+
|
10
|
+
### Additional Details
|
11
|
+
* Last updated: Sun, 07 Mar 2021 10:42:17 GMT
|
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
|
+
* Global values: `React`
|
14
|
+
|
15
|
+
# Credits
|
16
|
+
These definitions were written by [Asana](https://asana.com), [AssureSign](http://www.assuresign.com), [Microsoft](https://microsoft.com), [John Reilly](https://github.com/johnnyreilly), [Benoit Benezech](https://github.com/bbenezech), [Patricio Zavolinsky](https://github.com/pzavolinsky), [Digiguru](https://github.com/digiguru), [Eric Anderson](https://github.com/ericanderson), [Dovydas Navickas](https://github.com/DovydasNavickas), [Josh Rutherford](https://github.com/theruther4d), [Guilherme Hübner](https://github.com/guilhermehubner), [Ferdy Budhidharma](https://github.com/ferdaber), [Johann Rakotoharisoa](https://github.com/jrakotoharisoa), [Olivier Pascal](https://github.com/pascaloliv), [Martin Hochel](https://github.com/hotell), [Frank Li](https://github.com/franklixuefei), [Jessica Franco](https://github.com/Jessidhia), [Saransh Kataria](https://github.com/saranshkataria), [Kanitkorn Sujautra](https://github.com/lukyth), [Sebastian Silbermann](https://github.com/eps1lon), [Kyle Scully](https://github.com/zieka), [Cong Zhang](https://github.com/dancerphil), [Dimitri Mitropoulos](https://github.com/dimitropoulos), [JongChan Choi](https://github.com/disjukr), [Victor Magalhães](https://github.com/vhfmag), and [Dale Tan](https://github.com/hellatan).
|
react/experimental.d.ts
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
/**
|
2
|
+
* These are types for things that are present in the `experimental` builds of React but not yet
|
3
|
+
* on a stable build.
|
4
|
+
*
|
5
|
+
* Once they are promoted to stable they can just be moved to the main index file.
|
6
|
+
*
|
7
|
+
* To load the types declared here in an actual project, there are three ways. The easiest one,
|
8
|
+
* if your `tsconfig.json` already has a `"types"` array in the `"compilerOptions"` section,
|
9
|
+
* is to add `"react/experimental"` to the `"types"` array.
|
10
|
+
*
|
11
|
+
* Alternatively, a specific import syntax can to be used from a typescript file.
|
12
|
+
* This module does not exist in reality, which is why the {} is important:
|
13
|
+
*
|
14
|
+
* ```ts
|
15
|
+
* import {} from 'react/experimental'
|
16
|
+
* ```
|
17
|
+
*
|
18
|
+
* It is also possible to include it through a triple-slash reference:
|
19
|
+
*
|
20
|
+
* ```ts
|
21
|
+
* /// <reference types="react/experimental" />
|
22
|
+
* ```
|
23
|
+
*
|
24
|
+
* Either the import or the reference only needs to appear once, anywhere in the project.
|
25
|
+
*/
|
26
|
+
|
27
|
+
// See https://github.com/facebook/react/blob/master/packages/react/src/React.js to see how the exports are declared,
|
28
|
+
// and https://github.com/facebook/react/blob/master/packages/shared/ReactFeatureFlags.js to verify which APIs are
|
29
|
+
// flagged experimental or not. Experimental APIs will be tagged with `__EXPERIMENTAL__`.
|
30
|
+
//
|
31
|
+
// For the inputs of types exported as simply a fiber tag, the `beginWork` function of ReactFiberBeginWork.js
|
32
|
+
// is a good place to start looking for details; it generally calls prop validation functions or delegates
|
33
|
+
// all tasks done as part of the render phase (the concurrent part of the React update cycle).
|
34
|
+
//
|
35
|
+
// Suspense-related handling can be found in ReactFiberThrow.js.
|
36
|
+
|
37
|
+
import React = require('.');
|
38
|
+
|
39
|
+
export {};
|
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
|
+
export interface SuspenseConfig {
|
110
|
+
busyDelayMs?: number;
|
111
|
+
busyMinDurationMs?: number;
|
112
|
+
}
|
113
|
+
|
114
|
+
// undocumented, considered for removal
|
115
|
+
export function unstable_withSuspenseConfig(
|
116
|
+
scope: () => VoidOrUndefinedOnly,
|
117
|
+
config: SuspenseConfig | null | undefined,
|
118
|
+
): void;
|
119
|
+
|
120
|
+
// must be synchronous
|
121
|
+
export type TransitionFunction = () => VoidOrUndefinedOnly;
|
122
|
+
// strange definition to allow vscode to show documentation on the invocation
|
123
|
+
export interface TransitionStartFunction {
|
124
|
+
/**
|
125
|
+
* State updates caused inside the callback are allowed to be deferred.
|
126
|
+
*
|
127
|
+
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
128
|
+
*
|
129
|
+
* @param callback A _synchronous_ function which causes state updates that can be deferred.
|
130
|
+
*/
|
131
|
+
(callback: TransitionFunction): void;
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Returns a deferred version of the value that may “lag behind” it for at most `timeoutMs`.
|
136
|
+
*
|
137
|
+
* This is commonly used to keep the interface responsive when you have something that renders immediately
|
138
|
+
* based on user input and something that needs to wait for a data fetch.
|
139
|
+
*
|
140
|
+
* A good example of this is a text input.
|
141
|
+
*
|
142
|
+
* @param value The value that is going to be deferred
|
143
|
+
*
|
144
|
+
* @see https://reactjs.org/docs/concurrent-mode-reference.html#usedeferredvalue
|
145
|
+
*/
|
146
|
+
export function unstable_useDeferredValue<T>(value: T): T;
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Allows components to avoid undesirable loading states by waiting for content to load
|
150
|
+
* before transitioning to the next screen. It also allows components to defer slower,
|
151
|
+
* data fetching updates until subsequent renders so that more crucial updates can be
|
152
|
+
* rendered immediately.
|
153
|
+
*
|
154
|
+
* The `useTransition` hook returns two values in an array.
|
155
|
+
*
|
156
|
+
* The first is a function that takes a callback. We can use it to tell React which state we want to defer.
|
157
|
+
* The seconda boolean. It’s React’s way of informing us whether we’re waiting for the transition to finish.
|
158
|
+
*
|
159
|
+
* **If some state update causes a component to suspend, that state update should be wrapped in a transition.**
|
160
|
+
*
|
161
|
+
* @param config An optional object with `timeoutMs`
|
162
|
+
*
|
163
|
+
* @see https://reactjs.org/docs/concurrent-mode-reference.html#usetransition
|
164
|
+
*/
|
165
|
+
export function unstable_useTransition(config?: SuspenseConfig | null): [TransitionStartFunction, boolean];
|
166
|
+
|
167
|
+
const opaqueIdentifierBranding: unique symbol;
|
168
|
+
/**
|
169
|
+
* WARNING: Don't use this as a `string`.
|
170
|
+
*
|
171
|
+
* This is an opaque type that is not supposed to type-check structurally.
|
172
|
+
* It is only valid if returned from React methods and passed to React e.g. `<button aria-labelledby={opaqueIdentifier} />`
|
173
|
+
*/
|
174
|
+
// We can't create a type that would be rejected for string concatenation or `.toString()` calls.
|
175
|
+
// So in order to not have to add `string | OpaqueIdentifier` to every react-dom host prop we intersect it with `string`.
|
176
|
+
type OpaqueIdentifier = string & {
|
177
|
+
readonly [opaqueIdentifierBranding]: unknown;
|
178
|
+
// While this would cause `const stringified: string = opaqueIdentifier.toString()` to not type-check it also adds completions while typing.
|
179
|
+
// It would also still allow string concatenation.
|
180
|
+
// Unsure which is better. Not type-checking or not suggesting.
|
181
|
+
// toString(): void;
|
182
|
+
};
|
183
|
+
|
184
|
+
export function unstable_useOpaqueIdentifier(): OpaqueIdentifier;
|
185
|
+
|
186
|
+
/**
|
187
|
+
* Similar to `useTransition` but allows uses where hooks are not available.
|
188
|
+
*
|
189
|
+
* @param callback A _synchronous_ function which causes state updates that can be deferred.
|
190
|
+
*/
|
191
|
+
export function unstable_startTransition(scope: TransitionFunction): void;
|
192
|
+
}
|
File without changes
|