Flow: well formed exports for smaller packages (#25361)
Enforces well formed exports for packages where the fixes are small.
Jan Kassens committed
Oct 3, 2022 at 16:52 UTC
9143864ae1f6d3e8158e5670f5a8623dc6c47dbf
6 files changed
+47
-35
packages/react-devtools-core/src/standalone.js
+5
-3
@@ -57,7 +57,7 @@ function hookNamesModuleLoaderFunction() {
57
);
58
}
59
60
-function setContentDOMNode(value: HTMLElement) {
60
+function setContentDOMNode(value: HTMLElement): typeof DevtoolsUI {
61
node = value;
62
63
// Save so we can restore the exact waiting message between sessions.
@@ -70,12 +70,14 @@ function setProjectRoots(value: Array<string>) {
70
projectRoots = value;
71
}
72
73
-function setStatusListener(value: StatusListener) {
73
+function setStatusListener(value: StatusListener): typeof DevtoolsUI {
74
statusListener = value;
75
return DevtoolsUI;
76
}
77
78
-function setDisconnectedCallback(value: OnDisconnectedCallback) {
78
+function setDisconnectedCallback(
79
+ value: OnDisconnectedCallback,
80
+): typeof DevtoolsUI {
81
disconnectedCallback = value;
82
return DevtoolsUI;
83
}
packages/react-is/src/ReactIs.js
+1
-1
@@ -26,7 +26,7 @@ import {
26
} from 'shared/ReactSymbols';
27
import isValidElementType from 'shared/isValidElementType';
28
29
-export function typeOf(object: any) {
29
+export function typeOf(object: any): mixed {
30
if (typeof object === 'object' && object !== null) {
31
const $$typeof = object.$$typeof;
32
switch ($$typeof) {
packages/react-refresh/src/ReactFreshRuntime.js
+6
-1
@@ -637,7 +637,12 @@ export function _getMountedRootCount(): number {
637
// 'useState{[foo, setFoo]}(0)',
638
// () => [useCustomHook], /* Lazy to avoid triggering inline requires */
639
// );
640
-export function createSignatureFunctionForTransform() {
640
+export function createSignatureFunctionForTransform(): <T>(
641
+ type: T,
642
+ key: string,
643
+ forceReset?: boolean,
644
+ getCustomHooks?: () => Array<Function>,
645
+) => T | void {
646
if (__DEV__) {
647
let savedType;
648
let hasCustomHooks;
packages/react-server/src/ReactFlightHooks.js
+4
-2
@@ -122,12 +122,14 @@ function unsupportedRefresh(): void {
122
123
let currentCache: Map<Function, mixed> | null = null;
124
125
-export function setCurrentCache(cache: Map<Function, mixed> | null) {
125
+export function setCurrentCache(
126
+ cache: Map<Function, mixed> | null,
127
+): Map<Function, mixed> | null {
128
currentCache = cache;
129
return currentCache;
130
}
131
130
-export function getCurrentCache() {
132
+export function getCurrentCache(): Map<Function, mixed> | null {
133
return currentCache;
134
}
135
packages/use-sync-external-store/src/useSyncExternalStoreShim.js
+5
-2
@@ -14,5 +14,8 @@ import {useSyncExternalStore as builtInAPI} from 'react';
14
15
const shim = isServerEnvironment ? server : client;
16
17
-export const useSyncExternalStore =
18
- builtInAPI !== undefined ? ((builtInAPI: any): typeof shim) : shim;
17
+export const useSyncExternalStore: <T>(
18
+ subscribe: (() => void) => () => void,
19
+ getSnapshot: () => T,
20
+ getServerSnapshot?: () => T,
21
+) => T = builtInAPI !== undefined ? builtInAPI : shim;
scripts/flow/config/flowconfig
+26
-26
@@ -48,43 +48,43 @@ munge_underscores=false
48
types_first=false
49
50
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
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
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
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
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
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
86
+well_formed_exports.includes=<PROJECT_ROOT>/packages/use-subscription
87
+well_formed_exports.includes=<PROJECT_ROOT>/packages/use-sync-external-store
88
89
# Substituted by createFlowConfig.js:
90
%REACT_RENDERER_FLOW_OPTIONS%