Flow: complete types first migration (#25389)
This complete the "types first" migration and enables the config everywhere.
Jan Kassens committed
Oct 3, 2022 at 21:59 UTC
0a3072278ee5fb46ddb58e6f5ba9e2b78f6f715a
33 files changed
+133
-107
packages/react-devtools-shared/src/node_modules/react-window/src/FixedSizeGrid.js
+3
-1
@@ -1,10 +1,12 @@
1
// @flow
2
3
+import type {ComponentType} from "react";
4
+
5
import createGridComponent from './createGridComponent';
6
7
import type { Props, ScrollToAlign } from './createGridComponent';
8
7
-const FixedSizeGrid = createGridComponent({
9
+const FixedSizeGrid: ComponentType<Props<$FlowFixMe>> = createGridComponent({
10
getColumnOffset: ({ columnWidth }: Props<any>, index: number): number =>
11
index * ((columnWidth: any): number),
12
packages/react-devtools-shared/src/node_modules/react-window/src/FixedSizeList.js
+3
-1
@@ -1,10 +1,12 @@
1
// @flow
2
3
+import type {ComponentType} from "react";
4
+
5
import createListComponent from './createListComponent';
6
7
import type { Props, ScrollToAlign } from './createListComponent';
8
7
-const FixedSizeList = createListComponent({
9
+const FixedSizeList: ComponentType<Props<$FlowFixMe>> = createListComponent({
10
getItemOffset: ({ itemSize }: Props<any>, index: number): number =>
11
index * ((itemSize: any): number),
12
packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeGrid.js
+3
-1
@@ -1,5 +1,7 @@
1
// @flow
2
3
+import type {ComponentType} from "react";
4
+
5
import createGridComponent from './createGridComponent';
6
7
import type { Props, ScrollToAlign } from './createGridComponent';
@@ -286,7 +288,7 @@ const getOffsetForIndexAndAlignment = (
288
}
289
};
290
289
-const VariableSizeGrid = createGridComponent({
291
+const VariableSizeGrid: ComponentType<Props<$FlowFixMe>> = createGridComponent({
292
getColumnOffset: (
293
props: Props<any>,
294
index: number,
packages/react-devtools-shared/src/node_modules/react-window/src/VariableSizeList.js
+3
-1
@@ -1,5 +1,7 @@
1
// @flow
2
3
+import type {ComponentType} from "react";
4
+
5
import createListComponent from './createListComponent';
6
7
import type { Props, ScrollToAlign } from './createListComponent';
@@ -163,7 +165,7 @@ const getEstimatedTotalSize = (
165
return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
166
};
167
166
-const VariableSizeList = createListComponent({
168
+const VariableSizeList: ComponentType<Props<any>> = createListComponent({
169
getItemOffset: (
170
props: Props<any>,
171
index: number,
packages/react-dom-bindings/src/client/ReactDOMInput.js
+1
-1
@@ -59,7 +59,7 @@ function isControlled(props) {
59
* See http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
60
*/
61
62
-export function getHostProps(element: Element, props: Object) {
62
+export function getHostProps(element: Element, props: Object): Object {
63
const node = ((element: any): InputWithWrapperState);
64
const checked = props.checked;
65
packages/react-dom-bindings/src/client/ReactDOMSelect.js
+1
-1
@@ -134,7 +134,7 @@ function updateOptions(
134
* selected.
135
*/
136
137
-export function getHostProps(element: Element, props: Object) {
137
+export function getHostProps(element: Element, props: Object): Object {
138
return assign({}, props, {
139
value: undefined,
140
});
packages/react-dom-bindings/src/client/ReactDOMTextarea.js
+1
-1
@@ -37,7 +37,7 @@ type TextAreaWithWrapperState = HTMLTextAreaElement & {
37
* `defaultValue` if specified, or the children content (deprecated).
38
*/
39
40
-export function getHostProps(element: Element, props: Object) {
40
+export function getHostProps(element: Element, props: Object): Object {
41
const node = ((element: any): TextAreaWithWrapperState);
42
43
if (props.dangerouslySetInnerHTML != null) {
packages/react-dom-bindings/src/client/setInnerHTML.js
+4
-1
@@ -21,7 +21,10 @@ let reusableSVGContainer;
21
* @param {string} html
22
* @internal
23
*/
24
-const setInnerHTML = createMicrosoftUnsafeLocalFunction(function(
24
+const setInnerHTML: (
25
+ node: Element,
26
+ html: {valueOf(): {toString(): string, ...}, ...},
27
+) => void = createMicrosoftUnsafeLocalFunction(function(
28
node: Element,
29
html: {valueOf(): {toString(): string, ...}, ...},
30
): void {
packages/react-dom-bindings/src/events/EventRegistry.js
+6
-2
@@ -21,7 +21,9 @@ if (enableCreateEventHandleAPI) {
21
/**
22
* Mapping from registration name to event name
23
*/
24
-export const registrationNameDependencies = {};
24
+export const registrationNameDependencies: {
25
+ [registrationName: string]: Array<DOMEventName>,
26
+} = {};
27
28
/**
29
* Mapping from lowercase registration names to the properly cased version,
@@ -29,7 +31,9 @@ export const registrationNameDependencies = {};
31
* only in __DEV__.
32
* @type {Object}
33
*/
32
-export const possibleRegistrationNames = __DEV__ ? {} : (null: any);
34
+export const possibleRegistrationNames: {
35
+ [lowerCasedName: string]: string,
36
+} = __DEV__ ? {} : (null: any);
37
// Trust the developer to only use possibleRegistrationNames in __DEV__
38
39
export function registerTwoPhaseEvent(
packages/react-dom-bindings/src/events/ReactDOMEventListener.js
+5
-5
@@ -8,7 +8,7 @@
8
*/
9
10
import type {AnyNativeEvent} from '../events/PluginModuleType';
11
-import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
11
+import type {Fiber, FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
12
import type {Container, SuspenseInstance} from '../client/ReactDOMHostConfig';
13
import type {DOMEventName} from '../events/DOMEventNames';
14
import {enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay} from 'shared/ReactFeatureFlags';
@@ -58,15 +58,15 @@ import {isRootDehydrated} from 'react-reconciler/src/ReactFiberShellHydration';
58
const {ReactCurrentBatchConfig} = ReactSharedInternals;
59
60
// TODO: can we stop exporting these?
61
-export let _enabled = true;
61
+export let _enabled: boolean = true;
62
63
// This is exported in FB builds for use by legacy FB layer infra.
64
// We'd like to remove this but it's not clear if this is safe.
65
-export function setEnabled(enabled: ?boolean) {
65
+export function setEnabled(enabled: ?boolean): void {
66
_enabled = !!enabled;
67
}
68
69
-export function isEnabled() {
69
+export function isEnabled(): boolean {
70
return _enabled;
71
}
72
@@ -348,7 +348,7 @@ function dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEve
348
);
349
}
350
351
-export let return_targetInst = null;
351
+export let return_targetInst: null | Fiber = null;
352
353
// Returns a SuspenseInstance or Container if it's blocked.
354
// The return_targetInst field above is conceptually part of the return value.
packages/react-dom-bindings/src/events/SyntheticEvent.js
+25
-14
@@ -16,7 +16,6 @@ import getEventCharCode from './getEventCharCode';
16
17
type EventInterfaceType = {
18
[propName: string]: 0 | ((event: {[propName: string]: mixed, ...}) => mixed),
19
- ...,
19
};
20
21
function functionThatReturnsTrue() {
@@ -153,14 +152,16 @@ const EventInterface = {
152
defaultPrevented: 0,
153
isTrusted: 0,
154
};
156
-export const SyntheticEvent = createSyntheticEvent(EventInterface);
155
+export const SyntheticEvent: $FlowFixMe = createSyntheticEvent(EventInterface);
156
157
const UIEventInterface: EventInterfaceType = {
158
...EventInterface,
159
view: 0,
160
detail: 0,
161
};
163
-export const SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
162
+export const SyntheticUIEvent: $FlowFixMe = createSyntheticEvent(
163
+ UIEventInterface,
164
+);
165
166
let lastMovementX;
167
let lastMovementY;
@@ -225,7 +226,9 @@ const MouseEventInterface: EventInterfaceType = {
226
return lastMovementY;
227
},
228
};
228
-export const SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
229
+export const SyntheticMouseEvent: $FlowFixMe = createSyntheticEvent(
230
+ MouseEventInterface,
231
+);
232
233
/**
234
* @interface DragEvent
@@ -235,7 +238,9 @@ const DragEventInterface: EventInterfaceType = {
238
...MouseEventInterface,
239
dataTransfer: 0,
240
};
238
-export const SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
241
+export const SyntheticDragEvent: $FlowFixMe = createSyntheticEvent(
242
+ DragEventInterface,
243
+);
244
245
/**
246
* @interface FocusEvent
@@ -245,7 +250,9 @@ const FocusEventInterface: EventInterfaceType = {
250
...UIEventInterface,
251
relatedTarget: 0,
252
};
248
-export const SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
253
+export const SyntheticFocusEvent: $FlowFixMe = createSyntheticEvent(
254
+ FocusEventInterface,
255
+);
256
257
/**
258
* @interface Event
@@ -258,7 +265,7 @@ const AnimationEventInterface: EventInterfaceType = {
265
elapsedTime: 0,
266
pseudoElement: 0,
267
};
261
-export const SyntheticAnimationEvent = createSyntheticEvent(
268
+export const SyntheticAnimationEvent: $FlowFixMe = createSyntheticEvent(
269
AnimationEventInterface,
270
);
271
@@ -274,7 +281,7 @@ const ClipboardEventInterface: EventInterfaceType = {
281
: window.clipboardData;
282
},
283
};
277
-export const SyntheticClipboardEvent = createSyntheticEvent(
284
+export const SyntheticClipboardEvent: $FlowFixMe = createSyntheticEvent(
285
ClipboardEventInterface,
286
);
287
@@ -286,7 +293,7 @@ const CompositionEventInterface: EventInterfaceType = {
293
...EventInterface,
294
data: 0,
295
};
289
-export const SyntheticCompositionEvent = createSyntheticEvent(
296
+export const SyntheticCompositionEvent: $FlowFixMe = createSyntheticEvent(
297
CompositionEventInterface,
298
);
299
@@ -487,7 +494,7 @@ const KeyboardEventInterface = {
494
return 0;
495
},
496
};
490
-export const SyntheticKeyboardEvent = createSyntheticEvent(
497
+export const SyntheticKeyboardEvent: $FlowFixMe = createSyntheticEvent(
498
KeyboardEventInterface,
499
);
500
@@ -508,7 +515,7 @@ const PointerEventInterface = {
515
pointerType: 0,
516
isPrimary: 0,
517
};
511
-export const SyntheticPointerEvent = createSyntheticEvent(
518
+export const SyntheticPointerEvent: $FlowFixMe = createSyntheticEvent(
519
PointerEventInterface,
520
);
521
@@ -527,7 +534,9 @@ const TouchEventInterface = {
534
shiftKey: 0,
535
getModifierState: getEventModifierState,
536
};
530
-export const SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
537
+export const SyntheticTouchEvent: $FlowFixMe = createSyntheticEvent(
538
+ TouchEventInterface,
539
+);
540
541
/**
542
* @interface Event
@@ -540,7 +549,7 @@ const TransitionEventInterface = {
549
elapsedTime: 0,
550
pseudoElement: 0,
551
};
543
-export const SyntheticTransitionEvent = createSyntheticEvent(
552
+export const SyntheticTransitionEvent: $FlowFixMe = createSyntheticEvent(
553
TransitionEventInterface,
554
);
555
@@ -580,4 +589,6 @@ const WheelEventInterface = {
589
// ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
590
deltaMode: 0,
591
};
583
-export const SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
592
+export const SyntheticWheelEvent: $FlowFixMe = createSyntheticEvent(
593
+ WheelEventInterface,
594
+);
packages/react-dom-bindings/src/events/forks/EventListener-www.js
+4
-4
@@ -16,7 +16,7 @@ export function addEventBubbleListener(
16
target: EventTarget,
17
eventType: string,
18
listener: Function,
19
-) {
19
+): mixed {
20
return EventListenerWWW.listen(target, eventType, listener);
21
}
22
@@ -24,7 +24,7 @@ export function addEventCaptureListener(
24
target: EventTarget,
25
eventType: string,
26
listener: Function,
27
-) {
27
+): mixed {
28
return EventListenerWWW.capture(target, eventType, listener);
29
}
30
@@ -33,7 +33,7 @@ export function addEventCaptureListenerWithPassiveFlag(
33
eventType: string,
34
listener: Function,
35
passive: boolean,
36
-) {
36
+): mixed {
37
return EventListenerWWW.captureWithPassiveFlag(
38
target,
39
eventType,
@@ -47,7 +47,7 @@ export function addEventBubbleListenerWithPassiveFlag(
47
eventType: string,
48
listener: Function,
49
passive: boolean,
50
-) {
50
+): mixed {
51
return EventListenerWWW.bubbleWithPassiveFlag(
52
target,
53
eventType,
packages/react-dom/src/client/ReactDOM.js
+6
-3
@@ -8,7 +8,10 @@
8
*/
9
10
import type {ReactNodeList} from 'shared/ReactTypes';
11
-import type {Container} from 'react-dom-bindings/src/client/ReactDOMHostConfig';
11
+import type {
12
+ Container,
13
+ PublicInstance,
14
+} from 'react-dom-bindings/src/client/ReactDOMHostConfig';
15
import type {
16
RootType,
17
HydrateRootOptions,
@@ -125,7 +128,7 @@ function renderSubtreeIntoContainer(
128
element: React$Element<any>,
129
containerNode: Container,
130
callback: ?Function,
128
-) {
131
+): React$Component<any, any> | PublicInstance | null {
132
return unstable_renderSubtreeIntoContainer(
133
parentComponent,
134
element,
@@ -171,7 +174,7 @@ declare function flushSync<R>(fn: () => R): R;
174
// eslint-disable-next-line no-redeclare
175
declare function flushSync(): void;
176
// eslint-disable-next-line no-redeclare
174
-function flushSync(fn) {
177
+function flushSync<R>(fn: (() => R) | void): R | void {
178
if (__DEV__) {
179
if (isAlreadyRendering()) {
180
console.error(
packages/react-dom/src/client/ReactDOMLegacy.js
+9
-6
@@ -7,7 +7,10 @@
7
* @flow
8
*/
9
10
-import type {Container} from 'react-dom-bindings/src/client/ReactDOMHostConfig';
10
+import type {
11
+ Container,
12
+ PublicInstance,
13
+} from 'react-dom-bindings/src/client/ReactDOMHostConfig';
14
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
15
import type {ReactNodeList} from 'shared/ReactTypes';
16
@@ -206,7 +209,7 @@ function legacyRenderSubtreeIntoContainer(
209
container: Container,
210
forceHydrate: boolean,
211
callback: ?Function,
209
-) {
212
+): React$Component<any, any> | PublicInstance | null {
213
if (__DEV__) {
214
topLevelUpdateWarnings(container);
215
warnOnInvalidCallback(callback === undefined ? null : callback, 'render');
@@ -274,7 +277,7 @@ export function hydrate(
277
element: React$Node,
278
container: Container,
279
callback: ?Function,
277
-) {
280
+): React$Component<any, any> | PublicInstance | null {
281
if (__DEV__) {
282
console.error(
283
'ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot ' +
@@ -314,7 +317,7 @@ export function render(
317
element: React$Element<any>,
318
container: Container,
319
callback: ?Function,
317
-) {
320
+): React$Component<any, any> | PublicInstance | null {
321
if (__DEV__) {
322
console.error(
323
'ReactDOM.render is no longer supported in React 18. Use createRoot ' +
@@ -354,7 +357,7 @@ export function unstable_renderSubtreeIntoContainer(
357
element: React$Element<any>,
358
containerNode: Container,
359
callback: ?Function,
357
-) {
360
+): React$Component<any, any> | PublicInstance | null {
361
if (__DEV__) {
362
console.error(
363
'ReactDOM.unstable_renderSubtreeIntoContainer() is no longer supported ' +
@@ -381,7 +384,7 @@ export function unstable_renderSubtreeIntoContainer(
384
);
385
}
386
384
-export function unmountComponentAtNode(container: Container) {
387
+export function unmountComponentAtNode(container: Container): boolean {
388
if (!isValidContainerLegacy(container)) {
389
throw new Error(
390
'unmountComponentAtNode(...): Target container is not a DOM element.',
packages/react-native-renderer/src/ReactFabricHostConfig.js
+1
-1
@@ -593,7 +593,7 @@ export function replaceContainerChildren(
593
newChildren: ChildSet,
594
): void {}
595
596
-export function getInstanceFromNode(node: any) {
596
+export function getInstanceFromNode(node: any): empty {
597
throw new Error('Not yet implemented.');
598
}
599
packages/react-native-renderer/src/ReactNativeHostConfig.js
+1
-1
@@ -492,7 +492,7 @@ export function unhideTextInstance(
492
throw new Error('Not yet implemented.');
493
}
494
495
-export function getInstanceFromNode(node: any) {
495
+export function getInstanceFromNode(node: any): empty {
496
throw new Error('Not yet implemented.');
497
}
498
packages/react-native-renderer/src/legacy-events/accumulate.js
+2
@@ -39,6 +39,8 @@ function accumulate<T>(
39
}
40
41
if (isArray(next)) {
42
+ /* $FlowFixMe[incompatible-return] unsound if `next` is `T` and `T` an array,
43
+ * `isArray` might refine to the array element type of `T` */
44
return [current].concat(next);
45
}
46
packages/react-native-renderer/src/legacy-events/accumulateInto.js
+2
@@ -51,6 +51,8 @@ function accumulateInto<T>(
51
52
if (isArray(next)) {
53
// A bit too dangerous to mutate `next`.
54
+ /* $FlowFixMe[incompatible-return] unsound if `next` is `T` and `T` an array,
55
+ * `isArray` might refine to the array element type of `T` */
56
return [current].concat(next);
57
}
58
packages/react-reconciler/src/ReactFiberHostConfigWithNoHydration.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support hydration
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support hydration. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberHostConfigWithNoMicrotasks.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support microtasks
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support microtasks. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberHostConfigWithNoMutation.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support mutation
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support mutation. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberHostConfigWithNoPersistence.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support persistence
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support persistence. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberHostConfigWithNoResources.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support hydration
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support Resources. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberHostConfigWithNoScopes.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support React Scopes
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support React Scopes. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberHostConfigWithNoTestSelectors.js
+1
-1
@@ -10,7 +10,7 @@
10
// Renderers that don't support test selectors
11
// can re-export everything from this module.
12
13
-function shim(...args: any) {
13
+function shim(...args: any): empty {
14
throw new Error(
15
'The current renderer does not support test selectors. ' +
16
'This error is likely caused by a bug in React. ' +
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+1
-1
@@ -1565,7 +1565,7 @@ export function discreteUpdates<A, B, C, D, R>(
1565
// Warning, this opts-out of checking the function body.
1566
declare function flushSync<R>(fn: () => R): R;
1567
// eslint-disable-next-line no-redeclare
1568
-declare function flushSync(): void;
1568
+declare function flushSync(void): void;
1569
// eslint-disable-next-line no-redeclare
1570
export function flushSync<R>(fn: (() => R) | void): R | void {
1571
// In legacy mode, we flush pending passive effects at the beginning of the
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+1
-1
@@ -1565,7 +1565,7 @@ export function discreteUpdates<A, B, C, D, R>(
1565
// Warning, this opts-out of checking the function body.
1566
declare function flushSync<R>(fn: () => R): R;
1567
// eslint-disable-next-line no-redeclare
1568
-declare function flushSync(): void;
1568
+declare function flushSync(void): void;
1569
// eslint-disable-next-line no-redeclare
1570
export function flushSync<R>(fn: (() => R) | void): R | void {
1571
// In legacy mode, we flush pending passive effects at the beginning of the
packages/react-test-renderer/src/ReactTestHostConfig.js
+2
-2
@@ -57,7 +57,7 @@ if (__DEV__) {
57
Object.freeze(UPDATE_SIGNAL);
58
}
59
60
-export function getPublicInstance(inst: Instance | TextInstance): * {
60
+export function getPublicInstance(inst: Instance | TextInstance): $FlowFixMe {
61
switch (inst.tag) {
62
case 'INSTANCE':
63
const createNodeMock = inst.rootContainerInstance.createNodeMock;
@@ -283,7 +283,7 @@ export function unhideTextInstance(
283
textInstance.isHidden = false;
284
}
285
286
-export function getInstanceFromNode(mockNode: Object) {
286
+export function getInstanceFromNode(mockNode: Object): Object | null {
287
const instance = nodeToInstanceMap.get(mockNode);
288
if (instance !== undefined) {
289
return instance.internalInstanceHandle;
packages/react-test-renderer/src/ReactTestRenderer.js
+21
-5
@@ -9,7 +9,11 @@
9
10
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
11
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
12
-import type {Instance, TextInstance} from './ReactTestHostConfig';
12
+import type {
13
+ PublicInstance,
14
+ Instance,
15
+ TextInstance,
16
+} from './ReactTestHostConfig';
17
18
import * as React from 'react';
19
import * as Scheduler from 'scheduler/unstable_mock';
@@ -303,7 +307,7 @@ class ReactTestInstance {
307
this._fiber = fiber;
308
}
309
306
- get instance() {
310
+ get instance(): $FlowFixMe {
311
if (this._fiber.tag === HostComponent || this._fiber.tag === HostResource) {
312
return getPublicInstance(this._fiber.stateNode);
313
} else {
@@ -311,7 +315,7 @@ class ReactTestInstance {
315
}
316
}
317
314
- get type() {
318
+ get type(): any {
319
return this._fiber.type;
320
}
321
@@ -445,7 +449,19 @@ function onRecoverableError(error) {
449
console.error(error);
450
}
451
448
-function create(element: React$Element<any>, options: TestRendererOptions) {
452
+function create(
453
+ element: React$Element<any>,
454
+ options: TestRendererOptions,
455
+): {
456
+ _Scheduler: typeof Scheduler,
457
+ root: void,
458
+ toJSON(): Array<ReactTestRendererNode> | ReactTestRendererNode | null,
459
+ toTree(): mixed,
460
+ update(newElement: React$Element<any>): any,
461
+ unmount(): void,
462
+ getInstance(): React$Component<any, any> | PublicInstance | null,
463
+ unstable_flushSync: typeof flushSync,
464
+} {
465
let createNodeMock = defaultTestOptions.createNodeMock;
466
let isConcurrent = false;
467
let isStrictMode = false;
@@ -534,7 +550,7 @@ function create(element: React$Element<any>, options: TestRendererOptions) {
550
}
551
return toTree(root.current);
552
},
537
- update(newElement: React$Element<any>) {
553
+ update(newElement: React$Element<any>): number | void {
554
if (root == null || root.current == null) {
555
return;
556
}
packages/react/src/React.js
+9
-3
@@ -71,9 +71,15 @@ import {startTransition} from './ReactStartTransition';
71
import {act} from './ReactAct';
72
73
// TODO: Move this branching into the other module instead and just re-export.
74
-const createElement = __DEV__ ? createElementWithValidation : createElementProd;
75
-const cloneElement = __DEV__ ? cloneElementWithValidation : cloneElementProd;
76
-const createFactory = __DEV__ ? createFactoryWithValidation : createFactoryProd;
74
+const createElement: any = __DEV__
75
+ ? createElementWithValidation
76
+ : createElementProd;
77
+const cloneElement: any = __DEV__
78
+ ? cloneElementWithValidation
79
+ : cloneElementProd;
80
+const createFactory: any = __DEV__
81
+ ? createFactoryWithValidation
82
+ : createFactoryProd;
83
84
const Children = {
85
map,
packages/react/src/ReactDebugCurrentFrame.js
+8
-2
@@ -7,11 +7,17 @@
7
* @flow
8
*/
9
10
-const ReactDebugCurrentFrame = {};
10
+const ReactDebugCurrentFrame: {
11
+ setExtraStackFrame?: (stack: null | string) => void,
12
+ getCurrentStack?: null | (() => string),
13
+ getStackAddendum?: () => string,
14
+} =
15
+ // $FlowFixMe[incompatible-exact]
16
+ {};
17
18
let currentExtraStackFrame = (null: null | string);
19
14
-export function setExtraStackFrame(stack: null | string) {
20
+export function setExtraStackFrame(stack: null | string): void {
21
if (__DEV__) {
22
currentExtraStackFrame = stack;
23
}
packages/react/src/jsx/ReactJSX.js
+3
-3
@@ -13,10 +13,10 @@ import {
13
jsxWithValidation,
14
} from './ReactJSXElementValidator';
15
import {jsx as jsxProd} from './ReactJSXElement';
16
-const jsx = __DEV__ ? jsxWithValidationDynamic : jsxProd;
16
+const jsx: any = __DEV__ ? jsxWithValidationDynamic : jsxProd;
17
// we may want to special case jsxs internally to take advantage of static children.
18
// for now we can ship identical prod functions
19
-const jsxs = __DEV__ ? jsxWithValidationStatic : jsxProd;
20
-const jsxDEV = __DEV__ ? jsxWithValidation : undefined;
19
+const jsxs: any = __DEV__ ? jsxWithValidationStatic : jsxProd;
20
+const jsxDEV: any = __DEV__ ? jsxWithValidation : undefined;
21
22
export {REACT_FRAGMENT_TYPE as Fragment, jsx, jsxs, jsxDEV};
scripts/flow/config/flowconfig
+1
-39
@@ -45,46 +45,8 @@ esproposal.class_instance_fields=enable
45
esproposal.optional_chaining=enable
46
exact_by_default=true
47
munge_underscores=false
48
-types_first=false
49
-
48
+types_first=true
49
well_formed_exports=true
51
-well_formed_exports.includes=<PROJECT_ROOT>/packages/dom-event-testing-library
52
-well_formed_exports.includes=<PROJECT_ROOT>/packages/eslint-plugin-react-hooks
53
-well_formed_exports.includes=<PROJECT_ROOT>/packages/jest-mock-scheduler
54
-well_formed_exports.includes=<PROJECT_ROOT>/packages/jest-react
55
-; well_formed_exports.includes=<PROJECT_ROOT>/packages/react
56
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-art
57
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-cache
58
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-client
59
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-debug-tools
60
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools
61
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-core
62
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-extensions
63
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-inline
64
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-shared
65
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-shell
66
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-timeline
67
-; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-dom
68
-; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-dom-bindings
69
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fetch
70
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fs
71
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-interactions
72
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-is
73
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-native-renderer
74
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-noop-renderer
75
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-pg
76
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-reconciler
77
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-refresh
78
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server
79
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-dom-relay
80
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-dom-webpack
81
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-native-relay
82
-well_formed_exports.includes=<PROJECT_ROOT>/packages/react-suspense-test-utils
83
-; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-test-renderer
84
-well_formed_exports.includes=<PROJECT_ROOT>/packages/scheduler
85
-well_formed_exports.includes=<PROJECT_ROOT>/packages/shared
86
-well_formed_exports.includes=<PROJECT_ROOT>/packages/use-subscription
87
-well_formed_exports.includes=<PROJECT_ROOT>/packages/use-sync-external-store
50
51
# Substituted by createFlowConfig.js:
52
%REACT_RENDERER_FLOW_OPTIONS%