Skip to content

Commit 9143864

Browse files
authored
Flow: well formed exports for smaller packages (#25361)
Enforces well formed exports for packages where the fixes are small.
1 parent 94ac306 commit 9143864

File tree

6 files changed

+47
-35
lines changed

6 files changed

+47
-35
lines changed

packages/react-devtools-core/src/standalone.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function hookNamesModuleLoaderFunction() {
5757
);
5858
}
5959

60-
function setContentDOMNode(value: HTMLElement) {
60+
function setContentDOMNode(value: HTMLElement): typeof DevtoolsUI {
6161
node = value;
6262

6363
// Save so we can restore the exact waiting message between sessions.
@@ -70,12 +70,14 @@ function setProjectRoots(value: Array<string>) {
7070
projectRoots = value;
7171
}
7272

73-
function setStatusListener(value: StatusListener) {
73+
function setStatusListener(value: StatusListener): typeof DevtoolsUI {
7474
statusListener = value;
7575
return DevtoolsUI;
7676
}
7777

78-
function setDisconnectedCallback(value: OnDisconnectedCallback) {
78+
function setDisconnectedCallback(
79+
value: OnDisconnectedCallback,
80+
): typeof DevtoolsUI {
7981
disconnectedCallback = value;
8082
return DevtoolsUI;
8183
}

packages/react-is/src/ReactIs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
} from 'shared/ReactSymbols';
2727
import isValidElementType from 'shared/isValidElementType';
2828

29-
export function typeOf(object: any) {
29+
export function typeOf(object: any): mixed {
3030
if (typeof object === 'object' && object !== null) {
3131
const $$typeof = object.$$typeof;
3232
switch ($$typeof) {

packages/react-refresh/src/ReactFreshRuntime.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,12 @@ export function _getMountedRootCount(): number {
637637
// 'useState{[foo, setFoo]}(0)',
638638
// () => [useCustomHook], /* Lazy to avoid triggering inline requires */
639639
// );
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 {
641646
if (__DEV__) {
642647
let savedType;
643648
let hasCustomHooks;

packages/react-server/src/ReactFlightHooks.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,14 @@ function unsupportedRefresh(): void {
122122

123123
let currentCache: Map<Function, mixed> | null = null;
124124

125-
export function setCurrentCache(cache: Map<Function, mixed> | null) {
125+
export function setCurrentCache(
126+
cache: Map<Function, mixed> | null,
127+
): Map<Function, mixed> | null {
126128
currentCache = cache;
127129
return currentCache;
128130
}
129131

130-
export function getCurrentCache() {
132+
export function getCurrentCache(): Map<Function, mixed> | null {
131133
return currentCache;
132134
}
133135

packages/use-sync-external-store/src/useSyncExternalStoreShim.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ import {useSyncExternalStore as builtInAPI} from 'react';
1414

1515
const shim = isServerEnvironment ? server : client;
1616

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

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,43 @@ munge_underscores=false
4848
types_first=false
4949

5050
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
5555
; 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
6464
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-shared
6565
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-shell
6666
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-timeline
6767
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-dom
6868
; 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
7373
; 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
7676
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
8383
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-test-renderer
8484
well_formed_exports.includes=<PROJECT_ROOT>/packages/scheduler
8585
; 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
8888

8989
# Substituted by createFlowConfig.js:
9090
%REACT_RENDERER_FLOW_OPTIONS%

0 commit comments

Comments
 (0)