Flow: well formed exports for smaller packages (#25361)

Enforces well formed exports for packages where the fixes are small.
This commit is contained in:
Jan Kassens
2022-10-03 16:52:41 -04:00
committed by GitHub
parent 94ac306688
commit 9143864ae1
6 changed files with 47 additions and 35 deletions

View File

@@ -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.
@@ -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;
}

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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%