Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use declare const instead of declare var #28599

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// So `$$$config` looks like a global variable, but it's
// really an argument to a top-level wrapping function.

declare var $$$config: any;
declare const $$$config: any;

export opaque type ModuleLoading = mixed;
export opaque type SSRModuleMap = mixed;
Expand Down
18 changes: 9 additions & 9 deletions packages/react-devtools-extensions/flow-typed/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ declare function beforeAll(
): void;

/** A context for grouping tests together */
declare var describe: {
declare const describe: {
/**
* Creates a block that groups together several related tests in one "test suite"
*/
Expand Down Expand Up @@ -991,7 +991,7 @@ declare var describe: {
};

/** An individual test unit */
declare var it: {
declare const it: {
/**
* An individual test unit
*
Expand Down Expand Up @@ -1079,15 +1079,15 @@ declare function fit(
timeout?: number
): void;
/** An individual test unit */
declare var test: typeof it;
declare const test: typeof it;
/** A disabled group of tests */
declare var xdescribe: typeof describe;
declare const xdescribe: typeof describe;
/** A focused group of tests */
declare var fdescribe: typeof describe;
declare const fdescribe: typeof describe;
/** A disabled individual test */
declare var xit: typeof it;
declare const xit: typeof it;
/** A disabled individual test */
declare var xtest: typeof it;
declare const xtest: typeof it;

type JestPrettyFormatColors = {
comment: {close: string, open: string},
Expand Down Expand Up @@ -1139,7 +1139,7 @@ type JestPrettyFormatPlugin = {
type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;

/** The expect function is used every time you want to test a value */
declare var expect: {
declare const expect: {
/** The object that you want to make assertions against */
(
value: any
Expand Down Expand Up @@ -1173,4 +1173,4 @@ declare var expect: {
};

/** Holds all functions related to manipulating test runner */
declare var jest: JestObjectType;
declare const jest: JestObjectType;
2 changes: 1 addition & 1 deletion packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export type NativeMethods = $ReadOnly<{|
|}>;

// This validates that INativeMethods and NativeMethods stay in sync using Flow!
declare var ensureNativeMethodsAreSynced: NativeMethods;
declare const ensureNativeMethodsAreSynced: NativeMethods;
(ensureNativeMethodsAreSynced: INativeMethods);

export type HostComponent<T> = AbstractComponent<T, $ReadOnly<NativeMethods>>;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberDevToolsHook.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
import {setSuppressWarning} from 'shared/consoleWithStackDev';
import {disableLogs, reenableLogs} from 'shared/ConsolePatchingDev';

declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void;
declare const __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void;

let rendererID = null;
let injectedHook = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// So `$$$config` looks like a global variable, but it's
// really an argument to a top-level wrapping function.

declare var $$$config: any;
declare const $$$config: any;
export opaque type Type = mixed; // eslint-disable-line no-undef
export opaque type Props = mixed; // eslint-disable-line no-undef
export opaque type Container = mixed; // eslint-disable-line no-undef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

declare var $$$config: any;
declare const $$$config: any;

export opaque type ClientManifest = mixed;
export opaque type ClientReference<T> = mixed; // eslint-disable-line no-unused-vars
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server/src/forks/ReactFizzConfig.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import type {Request} from 'react-server/src/ReactFizzServer';
import type {TransitionStatus} from 'react-reconciler/src/ReactFiberConfig';

declare var $$$config: any;
declare const $$$config: any;
export opaque type Destination = mixed; // eslint-disable-line no-undef
export opaque type RenderState = mixed;
export opaque type HoistableState = mixed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// So `$$$config` looks like a global variable, but it's
// really an argument to a top-level wrapping function.

declare var $$$config: any;
declare const $$$config: any;
export opaque type Destination = mixed; // eslint-disable-line no-undef

export opaque type PrecomputedChunk = mixed; // eslint-disable-line no-undef
Expand Down
2 changes: 1 addition & 1 deletion packages/scheduler/src/forks/SchedulerNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type NativeSchedulerType = {
unstable_now: () => DOMHighResTimeStamp,
};

declare var nativeRuntimeScheduler: void | NativeSchedulerType;
declare const nativeRuntimeScheduler: void | NativeSchedulerType;

export const unstable_UserBlockingPriority: PriorityLevel =
typeof nativeRuntimeScheduler !== 'undefined'
Expand Down
48 changes: 24 additions & 24 deletions scripts/flow/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@

/* eslint-disable */

declare var __PROFILE__: boolean;
declare var __UMD__: boolean;
declare var __EXPERIMENTAL__: boolean;
declare var __VARIANT__: boolean;
declare const __PROFILE__: boolean;
declare const __UMD__: boolean;
declare const __EXPERIMENTAL__: boolean;
declare const __VARIANT__: boolean;

declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
declare const __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
inject: ?((stuff: Object) => void)
};*/

declare var globalThis: Object;
declare const globalThis: Object;

declare var queueMicrotask: (fn: Function) => void;
declare var reportError: (error: mixed) => void;
declare var AggregateError: Class<Error>;
declare const queueMicrotask: (fn: Function) => void;
declare const reportError: (error: mixed) => void;
declare const AggregateError: Class<Error>;

declare var FinalizationRegistry: any;
declare const FinalizationRegistry: any;

declare module 'create-react-class' {
declare var exports: React$CreateClass;
declare const exports: React$CreateClass;
}

// Flow hides the props of React$Element, this overrides it to unhide
Expand All @@ -43,7 +43,7 @@ declare opaque type React$Element<
+ref: any,
};

declare var trustedTypes: {
declare const trustedTypes: {
isHTML: (value: any) => boolean,
isScript: (value: any) => boolean,
isScriptURL: (value: any) => boolean,
Expand Down Expand Up @@ -89,22 +89,22 @@ declare module 'EventListener' {
}

declare function __webpack_chunk_load__(id: string): Promise<mixed>;
declare var __webpack_require__: ((id: string) => any) & {
declare const __webpack_require__: ((id: string) => any) & {
u: string => string,
};

declare function __turbopack_load__(id: string): Promise<mixed>;
declare var __turbopack_require__: ((id: string) => any) & {
declare const __turbopack_require__: ((id: string) => any) & {
u: string => string,
};

declare module 'fs/promises' {
declare var access: (path: string, mode?: number) => Promise<void>;
declare var lstat: (
declare const access: (path: string, mode?: number) => Promise<void>;
declare const lstat: (
path: string,
options?: ?{bigint?: boolean},
) => Promise<mixed>;
declare var readdir: (
declare const readdir: (
path: string,
options?:
| ?string
Expand All @@ -113,37 +113,37 @@ declare module 'fs/promises' {
withFileTypes?: ?boolean,
},
) => Promise<Buffer>;
declare var readFile: (
declare const readFile: (
path: string,
options?:
| ?string
| {
encoding?: ?string,
},
) => Promise<Buffer>;
declare var readlink: (
declare const readlink: (
path: string,
options?:
| ?string
| {
encoding?: ?string,
},
) => Promise<mixed>;
declare var realpath: (
declare const realpath: (
path: string,
options?:
| ?string
| {
encoding?: ?string,
},
) => Promise<mixed>;
declare var stat: (
declare const stat: (
path: string,
options?: ?{bigint?: boolean},
) => Promise<mixed>;
}
declare module 'pg' {
declare var Pool: (options: mixed) => {
declare const Pool: (options: mixed) => {
query: (query: string, values?: Array<mixed>) => void,
};
}
Expand Down Expand Up @@ -320,7 +320,7 @@ declare class AsyncLocalStorage<T> {
enterWith(store: T): void;
}

declare var async_hooks: {
declare const async_hooks: {
createHook(callbacks: any): any,
executionAsyncId(): number,
};
Expand All @@ -332,7 +332,7 @@ declare module 'node:worker_threads' {
}
}

declare var Bun: {
declare const Bun: {
hash(
input: string | $TypedArray | DataView | ArrayBuffer | SharedArrayBuffer,
): number,
Expand Down
16 changes: 8 additions & 8 deletions scripts/flow/react-devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

/* eslint-disable no-unused-vars */

declare var __EXTENSION__: boolean;
declare var __TEST__: boolean;
declare const __EXTENSION__: boolean;
declare const __TEST__: boolean;

declare var DARK_MODE_DIMMED_WARNING_COLOR: string;
declare var DARK_MODE_DIMMED_ERROR_COLOR: string;
declare var DARK_MODE_DIMMED_LOG_COLOR: string;
declare var LIGHT_MODE_DIMMED_WARNING_COLOR: string;
declare var LIGHT_MODE_DIMMED_ERROR_COLOR: string;
declare var LIGHT_MODE_DIMMED_LOG_COLOR: string;
declare const DARK_MODE_DIMMED_WARNING_COLOR: string;
declare const DARK_MODE_DIMMED_ERROR_COLOR: string;
declare const DARK_MODE_DIMMED_LOG_COLOR: string;
declare const LIGHT_MODE_DIMMED_WARNING_COLOR: string;
declare const LIGHT_MODE_DIMMED_ERROR_COLOR: string;
declare const LIGHT_MODE_DIMMED_LOG_COLOR: string;
20 changes: 10 additions & 10 deletions scripts/flow/react-native-host-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'
): boolean;
declare export function deepFreezeAndThrowOnMutationInDev<T>(obj: T): T;
declare export function flattenStyle(style: any): any;
declare export var RCTEventEmitter: {
declare export const RCTEventEmitter: {
register: (eventEmitter: mixed) => void,
...
};
declare export var TextInputState: {
declare export const TextInputState: {
blurTextInput: (object: any) => void,
focusTextInput: (object: any) => void,
...
};
declare export var ReactFiberErrorDialog: {
declare export const ReactFiberErrorDialog: {
showErrorDialog: (error: __CapturedError) => boolean,
...
};
declare export var Platform: {OS: string, ...};
declare export var UIManager: {
declare export const Platform: {OS: string, ...};
declare export const UIManager: {
customBubblingEventTypes: Object,
customDirectEventTypes: Object,
createView: (
Expand Down Expand Up @@ -123,23 +123,23 @@ declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'
) => void,
...
};
declare export var legacySendAccessibilityEvent: (
declare export const legacySendAccessibilityEvent: (
reactTag: number,
eventTypeName: string,
) => void;
declare export var BatchedBridge: {
declare export const BatchedBridge: {
registerCallableModule: (name: string, module: Object) => void,
...
};
declare export var ReactNativeViewConfigRegistry: {
declare export const ReactNativeViewConfigRegistry: {
customBubblingEventTypes: Object,
customDirectEventTypes: Object,

register: (name: string, callback: __ViewConfigGetter) => string,
get: (name: string) => __ReactNativeBaseComponentViewConfig,
...
};
declare export var RawEventEmitter: {
declare export const RawEventEmitter: {
emit: (channel: string, event: RawEventEmitterEvent) => string,
...
};
Expand Down Expand Up @@ -171,7 +171,7 @@ declare const RN$enableMicrotasksInReact: boolean;

// This is needed for a short term solution.
// See https://github.com/facebook/react/pull/15490 for more info
declare var nativeFabricUIManager: {
declare const nativeFabricUIManager: {
createNode: (
reactTag: number,
viewName: string,
Expand Down
24 changes: 12 additions & 12 deletions scripts/flow/xplat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
*/

declare module 'ReactNativeInternalFeatureFlags' {
declare export var alwaysThrottleDisappearingFallbacks: boolean;
declare export var alwaysThrottleRetries: boolean;
declare export var consoleManagedByDevToolsDuringStrictMode: boolean;
declare export var enableAsyncActions: boolean;
declare export var enableComponentStackLocations: boolean;
declare export var enableDeferRootSchedulingToMicrotask: boolean;
declare export var enableInfiniteRenderLoopDetection: boolean;
declare export var enableRenderableContext: boolean;
declare export var enableUnifiedSyncLane: boolean;
declare export var enableUseRefAccessWarning: boolean;
declare export var passChildrenWhenCloningPersistedNodes: boolean;
declare export var useModernStrictMode: boolean;
declare export const alwaysThrottleDisappearingFallbacks: boolean;
declare export const alwaysThrottleRetries: boolean;
declare export const consoleManagedByDevToolsDuringStrictMode: boolean;
declare export const enableAsyncActions: boolean;
declare export const enableComponentStackLocations: boolean;
declare export const enableDeferRootSchedulingToMicrotask: boolean;
declare export const enableInfiniteRenderLoopDetection: boolean;
declare export const enableRenderableContext: boolean;
declare export const enableUnifiedSyncLane: boolean;
declare export const enableUseRefAccessWarning: boolean;
declare export const passChildrenWhenCloningPersistedNodes: boolean;
declare export const useModernStrictMode: boolean;
}
Loading