Skip to content

Commit

Permalink
Flow: well formed exports for smaller packages
Browse files Browse the repository at this point in the history
Enforces well formed exports for packages where the fixes are small.
  • Loading branch information
kassens committed Oct 1, 2022
1 parent 9c3de25 commit aaad0e9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 35 deletions.
8 changes: 5 additions & 3 deletions packages/react-devtools-core/src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function hookNamesModuleLoaderFunction() {
);
}

function setContentDOMNode(value: HTMLElement) {
function setContentDOMNode(value: HTMLElement): typeof DevtoolsUI {
node = value;

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

function setStatusListener(value: StatusListener) {
function setStatusListener(value: StatusListener): typeof DevtoolsUI {
statusListener = value;
return DevtoolsUI;
}

function setDisconnectedCallback(value: OnDisconnectedCallback) {
function setDisconnectedCallback(
value: OnDisconnectedCallback,
): typeof DevtoolsUI {
disconnectedCallback = value;
return DevtoolsUI;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-is/src/ReactIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from 'shared/ReactSymbols';
import isValidElementType from 'shared/isValidElementType';

export function typeOf(object: any) {
export function typeOf(object: any): mixed {
if (typeof object === 'object' && object !== null) {
const $$typeof = object.$$typeof;
switch ($$typeof) {
Expand Down
7 changes: 6 additions & 1 deletion packages/react-refresh/src/ReactFreshRuntime.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,12 @@ export function _getMountedRootCount(): number {
// 'useState{[foo, setFoo]}(0)',
// () => [useCustomHook], /* Lazy to avoid triggering inline requires */
// );
export function createSignatureFunctionForTransform() {
export function createSignatureFunctionForTransform(): <T>(
type: T,
key: string,
forceReset?: boolean,
getCustomHooks?: () => Array<Function>,
) => T | void {
if (__DEV__) {
let savedType;
let hasCustomHooks;
Expand Down
6 changes: 4 additions & 2 deletions packages/react-server/src/ReactFlightHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ function unsupportedRefresh(): void {

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

export function setCurrentCache(cache: Map<Function, mixed> | null) {
export function setCurrentCache(
cache: Map<Function, mixed> | null,
): Map<Function, mixed> | null {
currentCache = cache;
return currentCache;
}

export function getCurrentCache() {
export function getCurrentCache(): Map<Function, mixed> | null {
return currentCache;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ import {useSyncExternalStore as builtInAPI} from 'react';

const shim = isServerEnvironment ? server : client;

export const useSyncExternalStore =
builtInAPI !== undefined ? ((builtInAPI: any): typeof shim) : shim;
export const useSyncExternalStore: <T>(
subscribe: (() => void) => () => void,
getSnapshot: () => T,
getServerSnapshot?: () => T,
) => T = builtInAPI !== undefined ? builtInAPI : shim;
52 changes: 26 additions & 26 deletions scripts/flow/config/flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,43 +48,43 @@ munge_underscores=false
types_first=false

well_formed_exports=true
; well_formed_exports.includes=<PROJECT_ROOT>/packages/dom-event-testing-library
; well_formed_exports.includes=<PROJECT_ROOT>/packages/eslint-plugin-react-hooks
; well_formed_exports.includes=<PROJECT_ROOT>/packages/jest-mock-scheduler
; well_formed_exports.includes=<PROJECT_ROOT>/packages/jest-react
well_formed_exports.includes=<PROJECT_ROOT>/packages/dom-event-testing-library
well_formed_exports.includes=<PROJECT_ROOT>/packages/eslint-plugin-react-hooks
well_formed_exports.includes=<PROJECT_ROOT>/packages/jest-mock-scheduler
well_formed_exports.includes=<PROJECT_ROOT>/packages/jest-react
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-art
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-cache
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-client
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-debug-tools
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-core
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-extensions
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-inline
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-art
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-cache
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-client
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-debug-tools
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-core
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-extensions
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-inline
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-shared
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-shell
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-devtools-timeline
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-dom
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-dom-bindings
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fetch
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fs
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-interactions
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-is
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fetch
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-fs
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-interactions
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-is
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-native-renderer
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-noop-renderer
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-pg
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-noop-renderer
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-pg
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-reconciler
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-refresh
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-dom-relay
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-dom-webpack
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-native-relay
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-suspense-test-utils
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-refresh
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-dom-relay
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-dom-webpack
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-server-native-relay
well_formed_exports.includes=<PROJECT_ROOT>/packages/react-suspense-test-utils
; well_formed_exports.includes=<PROJECT_ROOT>/packages/react-test-renderer
well_formed_exports.includes=<PROJECT_ROOT>/packages/scheduler
; well_formed_exports.includes=<PROJECT_ROOT>/packages/shared
; well_formed_exports.includes=<PROJECT_ROOT>/packages/use-subscription
; well_formed_exports.includes=<PROJECT_ROOT>/packages/use-sync-external-store
well_formed_exports.includes=<PROJECT_ROOT>/packages/use-subscription
well_formed_exports.includes=<PROJECT_ROOT>/packages/use-sync-external-store

# Substituted by createFlowConfig.js:
%REACT_RENDERER_FLOW_OPTIONS%
Expand Down

0 comments on commit aaad0e9

Please sign in to comment.