Cleanup legacy flow types in react-native (#56300)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56300

Changelog: [Internal]

Reviewed By: marcoww6

Differential Revision: D99004126

fbshipit-source-id: dfedc13c867cb768777e2ba65256a2c40ffb1d08
This commit is contained in:
Sam Zhou
2026-03-31 19:25:25 -07:00
committed by meta-codesync[bot]
parent 8e202de86e
commit 82bffce573
44 changed files with 106 additions and 105 deletions
+3 -3
View File
@@ -43,7 +43,7 @@ module.exports = {
'<rootDir>/packages/react-native/Libraries/Renderer',
'<rootDir>/packages/react-native/sdks/hermes/',
...PODS_LOCATIONS,
] /*:: as $ReadOnlyArray<string> */,
] /*:: as ReadonlyArray<string> */,
transformIgnorePatterns: ['node_modules/(?!@react-native/)'],
haste: {
defaultPlatform: 'ios',
@@ -52,12 +52,12 @@ module.exports = {
moduleFileExtensions: [
'fb.js',
...defaults.moduleFileExtensions,
] /*:: as $ReadOnlyArray<string> */,
] /*:: as ReadonlyArray<string> */,
modulePathIgnorePatterns: [
'scripts/.*/__fixtures__/',
'<rootDir>/packages/react-native/sdks/hermes/',
...PODS_LOCATIONS,
] /*:: as $ReadOnlyArray<string> */,
] /*:: as ReadonlyArray<string> */,
unmockedModulePathPatterns: [
'node_modules/react/',
'packages/react-native/Libraries/Renderer',
@@ -522,9 +522,9 @@ describe.each(['HTTP', 'HTTPS'])(
// Collect all connect events
const connectEvents: Array<
$ReadOnly<{
Readonly<{
event: string,
payload: $ReadOnly<{pageId: string, sessionId?: string}>,
payload: Readonly<{pageId: string, sessionId?: string}>,
}>,
> = [];
device.connect.mockImplementation(message => {
@@ -25,7 +25,7 @@ export interface ReadonlyURLSearchParams {
value: string,
name: string,
params: URLSearchParams,
) => mixed,
) => unknown,
thisArg: This,
): void;
toString(): string;
@@ -59,7 +59,7 @@ async function* asyncNumberGenerator(
}
// Async/await patterns
async function fetchData(url: string): Promise<{data: mixed}> {
async function fetchData(url: string): Promise<{data: unknown}> {
const response = await fetch(url);
const data = await response.json();
return {data};
@@ -159,7 +159,7 @@ function parseDate(
}
// Try-catch with optional binding
function safeJsonParse(input: string): mixed {
function safeJsonParse(input: string): unknown {
try {
return JSON.parse(input);
} catch {
@@ -182,7 +182,7 @@ const MyClass = class {
};
// Dynamic import (syntax only)
async function loadModule(): Promise<mixed> {
async function loadModule(): Promise<unknown> {
// $FlowExpectedError[cannot-resolve-module] - Testing dynamic import syntax
const module = await import('./some-module');
return module.default;
@@ -133,7 +133,7 @@ const testConfigs = [
function transformCode(
code: string,
options: {[string]: mixed},
options: {[string]: unknown},
): string | null {
const result = babel.transformSync(code, {
babelrc: false,
@@ -156,7 +156,7 @@ function ensureDirectoryExists(dir: string): void {
}
}
function makeHeader(description: string, options: {[string]: mixed}): string {
function makeHeader(description: string, options: {[string]: unknown}): string {
return `/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
@@ -11,13 +11,13 @@
'use strict';
function compareSnaps(
flowFixtures /*: $ReadOnly<{[string]: string}> */,
flowSnaps /*: $ReadOnly<{[string]: string}> */,
flowExtraCases /*: $ReadOnlyArray<string> */,
tsFixtures /*: $ReadOnly<{[string]: string}> */,
tsSnaps /*: $ReadOnly<{[string]: string}> */,
tsExtraCases /*: $ReadOnlyArray<string> */,
ignoredCases /*: $ReadOnlyArray<string> */,
flowFixtures /*: Readonly<{[string]: string}> */,
flowSnaps /*: Readonly<{[string]: string}> */,
flowExtraCases /*: ReadonlyArray<string> */,
tsFixtures /*: Readonly<{[string]: string}> */,
tsSnaps /*: Readonly<{[string]: string}> */,
tsExtraCases /*: ReadonlyArray<string> */,
ignoredCases /*: ReadonlyArray<string> */,
) {
const flowCases = Object.keys(flowFixtures).sort();
const tsCases = Object.keys(tsFixtures).sort();
@@ -68,8 +68,8 @@ function compareSnaps(
}
function compareTsArraySnaps(
tsSnaps /*: $ReadOnly<{[string]: string}> */,
tsExtraCases /*: $ReadOnlyArray<string> */,
tsSnaps /*: Readonly<{[string]: string}> */,
tsExtraCases /*: ReadonlyArray<string> */,
) {
for (const array2Case of tsExtraCases.filter(
name => name.indexOf('ARRAY2') !== -1,
@@ -199,7 +199,7 @@ function formatTypeAnnotation(annotation: CompleteTypeAnnotation): string {
let validUnionType;
try {
validUnionType = parseValidUnionType(annotation);
} catch (_e: mixed) {
} catch (_e: unknown) {
// parseValidUnionType throws for unsupported union types
return 'Union<mixed>';
}
@@ -105,7 +105,7 @@ describe('AccessibilityInfo', () => {
mockNativeAccessibilityManagerDefault.getCurrentPrefersCrossFadeTransitionsState =
null;
const result: mixed =
const result: unknown =
await AccessibilityInfo.prefersCrossFadeTransitions().catch(e => e);
invariant(
@@ -151,7 +151,7 @@ describe('AccessibilityInfo', () => {
mockNativeAccessibilityManagerDefault.getCurrentDarkerSystemColorsState =
null;
const result: mixed =
const result: unknown =
await AccessibilityInfo.isDarkerSystemColorsEnabled().catch(e => e);
invariant(
@@ -184,7 +184,7 @@ describe('AccessibilityInfo', () => {
mockNativeAccessibilityInfo.isHighTextContrastEnabled = null;
const result: mixed =
const result: unknown =
await AccessibilityInfo.isHighTextContrastEnabled().catch(e => e);
invariant(
@@ -95,7 +95,7 @@ test('loadBundleFromServer will throw for JSON responses', async () => {
mockDataResponse = JSON.stringify({message: 'Error thrown from Metro'});
mockRequestError = null;
const error: mixed = await loadBundleFromServer(
const error: unknown = await loadBundleFromServer(
'/Fail.bundle?platform=ios',
).catch(e => e);
@@ -112,7 +112,7 @@ test('loadBundleFromServer will throw LoadBundleFromServerError for request erro
mockDataResponse = '';
mockRequestError = 'Some error';
const error: mixed = await loadBundleFromServer(
const error: unknown = await loadBundleFromServer(
'/Fail.bundle?platform=ios',
).catch(e => e);
+1 -1
View File
@@ -47,7 +47,7 @@ function isMissingCliDependency(error /*: Error */) {
);
}
let cli /*: $ReadOnly<{
let cli /*: Readonly<{
bin: string,
loadConfig: $FlowFixMe,
run: () => void
+3 -3
View File
@@ -114,9 +114,9 @@ commands.push(codegenCommand);
const config = {
commands,
platforms: {} /*:: as {[string]: $ReadOnly<{
projectConfig: mixed,
dependencyConfig: mixed,
platforms: {} /*:: as {[string]: Readonly<{
projectConfig: unknown,
dependencyConfig: unknown,
}>} */,
};
@@ -26,7 +26,7 @@ const MODULES_PROTOCOLS_MM_TEMPLATE_PATH = path.join(
);
function generateCustomURLHandlers(
libraries /*: $ReadOnlyArray<$FlowFixMe> */,
libraries /*: ReadonlyArray<$FlowFixMe> */,
outputDir /*: string */,
) {
const iosAnnotations = parseiOSAnnotations(libraries);
@@ -19,7 +19,7 @@ const path = require('path');
function generateNativeCode(
outputPath /*: string */,
schemaInfos /*: $ReadOnlyArray<$FlowFixMe> */,
schemaInfos /*: ReadonlyArray<$FlowFixMe> */,
includesGeneratedCode /*: boolean */,
platform /*: string */,
forceOutputPath /*: boolean */ = false,
@@ -32,7 +32,7 @@ const MODULE_PROVIDERS_MM_TEMPLATE_PATH = path.join(
function generateRCTModuleProviders(
projectRoot /*: string */,
pkgJson /*: $FlowFixMe */,
libraries /*: $ReadOnlyArray<$FlowFixMe> */,
libraries /*: ReadonlyArray<$FlowFixMe> */,
outputDir /*: string */,
) {
fs.mkdirSync(outputDir, {recursive: true});
@@ -31,7 +31,7 @@ const THIRD_PARTY_COMPONENTS_MM_TEMPLATE_PATH = path.join(
);
function generateRCTThirdPartyComponents(
libraries /*: $ReadOnlyArray<$FlowFixMe> */,
libraries /*: ReadonlyArray<$FlowFixMe> */,
outputDir /*: string */,
) {
fs.mkdirSync(outputDir, {recursive: true});
@@ -17,7 +17,7 @@ const path = require('path');
const {globSync} = require('tinyglobby');
function generateSchemaInfos(
libraries /*: $ReadOnlyArray<$FlowFixMe> */,
libraries /*: ReadonlyArray<$FlowFixMe> */,
) /*: Array<$FlowFixMe> */ {
// $FlowFixMe[incompatible-type]
return libraries.map(generateSchemaInfo);
@@ -28,7 +28,7 @@ const UNSTABLE_MODULES_REQUIRING_MAIN_QUEUE_SETUP_PROVIDER_MM_TEMPLATE_PATH =
);
function generateUnstableModulesRequiringMainQueueSetupProvider(
libraries /*: $ReadOnlyArray<$FlowFixMe> */,
libraries /*: ReadonlyArray<$FlowFixMe> */,
outputDir /*: string */,
) {
const iosAnnotations = parseiOSAnnotations(libraries);
@@ -389,7 +389,7 @@ function isReactNativeCoreLibrary(libraryName /*: string */) /*: boolean */ {
* Validates that components are defined in at most one library.
*/
function parseiOSAnnotations(
libraries /*: $ReadOnlyArray<$FlowFixMe> */,
libraries /*: ReadonlyArray<$FlowFixMe> */,
) /*: {[string]: $FlowFixMe} */ {
const mLibraryMap /*: {[string]: $FlowFixMe} */ = {};
const cLibraryMap /*: {[string]: $FlowFixMe} */ = {};
@@ -14,7 +14,7 @@ const utils = require('./codegen-utils');
const fs = require('fs');
const path = require('path');
const GENERATORS /*: {[string]: {[string]: $ReadOnlyArray<string>}} */ = {
const GENERATORS /*: {[string]: {[string]: ReadonlyArray<string>}} */ = {
all: {
android: ['componentsAndroid', 'modulesAndroid', 'modulesCxx'],
ios: ['componentsIOS', 'modulesIOS', 'modulesCxx'],
+1 -1
View File
@@ -34,7 +34,7 @@ const argv = yargs
'Please provide platform, schema path, and output directory.',
).argv;
const GENERATORS /*: {[string]: $ReadOnlyArray<string>} */ = {
const GENERATORS /*: {[string]: ReadonlyArray<string>} */ = {
android: [],
ios: ['providerIOS'],
};
+3 -3
View File
@@ -14,7 +14,7 @@ const yargs = require('yargs');
import type {BuildFlavor, Destination, Platform} from './types';
*/
const platforms /*: $ReadOnlyArray<Platform> */ = [
const platforms /*: ReadonlyArray<Platform> */ = [
'ios',
'ios-simulator',
'mac-catalyst',
@@ -22,7 +22,7 @@ const platforms /*: $ReadOnlyArray<Platform> */ = [
// CI can't use commas in cache keys, so 'macOS,variant=Mac Catalyst' was creating troubles
// This map that converts from platforms to valid Xcodebuild destinations.
const platformToDestination /*: $ReadOnly<{|[Platform]: Destination|}> */ = {
const platformToDestination /*: Readonly<{|[Platform]: Destination|}> */ = {
ios: 'iOS',
'ios-simulator': 'iOS Simulator',
'mac-catalyst': 'macOS,variant=Mac Catalyst',
@@ -78,7 +78,7 @@ async function getCLIConfiguration() /*: Promise<?{|
compose: boolean,
|},
flavor: BuildFlavor,
destinations: $ReadOnlyArray<Destination>,
destinations: ReadonlyArray<Destination>,
identity: ?string,
|}> */ {
// Run input parsing
@@ -9,12 +9,12 @@
*/
/*::
export type PodSpecConfiguration = $ReadOnly<{
export type PodSpecConfiguration = Readonly<{
name: string,
headerPatterns: Array<string>,
headerDir?: string,
excludePatterns?: Array<string>,
subSpecs?: $ReadOnlyArray<PodSpecConfiguration>,
subSpecs?: ReadonlyArray<PodSpecConfiguration>,
preservePaths?: Array<string>,
} | {disabled: true}>;
*/
@@ -41,7 +41,7 @@ describe('ShadowTreeBranching', () => {
'Insert {type: "View", parentNativeID: (root), index: 0, nativeID: "view"}',
]);
let updatesBeforeEndOfTask: $ReadOnlyArray<string> = [];
let updatesBeforeEndOfTask: ReadonlyArray<string> = [];
Fantom.runTask(() => {
root.render(
@@ -68,7 +68,7 @@ describe('ShadowTreeBranching', () => {
it('should not skip intermediate React commits', () => {
const root = Fantom.createRoot();
let updatesBeforeEndOfTask: $ReadOnlyArray<string> = [];
let updatesBeforeEndOfTask: ReadonlyArray<string> = [];
// When rendered with `shouldTriggerIntermediate=false`, it renders two views
// both with blue background. When rendered with `shouldTriggerIntermediate=true`,
@@ -37,7 +37,7 @@ type Data = {
title: string,
};
const initialData: $ReadOnlyArray<Data> = [
const initialData: ReadonlyArray<Data> = [
{id: '1', title: 'Kate Bell'},
{id: '2', title: 'John Appleseed'},
{id: '3', title: 'Mark Zuckerberg'},
@@ -62,7 +62,7 @@ const timingConfig = {
};
function SwipeableListExample(): React.Node {
const [data, setData] = React.useState<$ReadOnlyArray<Data>>(initialData);
const [data, setData] = React.useState<ReadonlyArray<Data>>(initialData);
const handleRemove = useCallback((id: string) => {
setData(currentData => currentData.filter(item => item.id !== id));
+1 -1
View File
@@ -46,4 +46,4 @@ const config = {
module.exports = mergeConfig(
getDefaultConfig(__dirname),
config,
) /*:: as $ReadOnly<InputConfigT> */;
) /*:: as Readonly<InputConfigT> */;
@@ -26,7 +26,7 @@ module.exports = {
...baseConfig.moduleFileExtensions,
'cpp',
'h',
] /*:: as $ReadOnlyArray<string> */,
] /*:: as ReadonlyArray<string> */,
// This allows running Meta-internal tests with the `-test.fb.js` suffix.
testRegex: '/__tests__/.*-itest(\\.fb)?\\.js$',
testPathIgnorePatterns: [
+1 -1
View File
@@ -61,7 +61,7 @@ export function getBuckModesForPlatform({
}: {
enableCoverage: boolean,
enableOptimized: boolean,
}): $ReadOnlyArray<string> {
}): ReadonlyArray<string> {
let mode = enableCoverage ? 'code-coverage' : enableOptimized ? 'opt' : 'dev';
if (enableOptimized) {
+3 -2
View File
@@ -256,8 +256,9 @@ export function getDefinedEventHandlers(
}
// WARNING: This uses React private API (fiber internals).
// $FlowExpectedError[incompatible-type]
const memoizedProps = (instanceHandle as {memoizedProps?: {[string]: mixed}})
.memoizedProps;
const memoizedProps = (
instanceHandle as {memoizedProps?: {[string]: unknown}}
).memoizedProps;
if (memoizedProps == null) {
return [];
}
+1 -1
View File
@@ -229,7 +229,7 @@ async function buildFile(
/*::
type PackageJson = {
name: string,
exports?: {[subpath: string]: string | mixed},
exports?: {[subpath: string]: string | unknown},
};
*/
+6 -6
View File
@@ -163,9 +163,9 @@ async function buildDebuggerFrontend(
packagePath /*: string */,
scratchPath /*: string */,
localCheckoutPath /*: ?string */,
{branch, gclientSyncOptions, noBuild} /*: $ReadOnly<{
{branch, gclientSyncOptions, noBuild} /*: Readonly<{
branch: string,
gclientSyncOptions: $ReadOnly<{nohooks: boolean}>,
gclientSyncOptions: Readonly<{nohooks: boolean}>,
noBuild: boolean,
}>*/,
) /*: Promise<{checkoutPath: string}> */ {
@@ -244,7 +244,7 @@ async function checkoutDevToolsFrontend(
async function setupGclientWorkspace(
scratchPath /*: string */,
checkoutPath /*: string */,
{nohooks} /*: $ReadOnly<{nohooks: boolean}> */,
{nohooks} /*: Readonly<{nohooks: boolean}> */,
) {
process.stdout.write('Setting up gclient workspace' + '\n');
await spawnSafe(
@@ -345,12 +345,12 @@ async function copyLicenseToPackage(
}
async function generateBuildInfo(
info /*: $ReadOnly<{
info /*: Readonly<{
checkoutPath: string,
isLocalCheckout: boolean,
branch: string,
packagePath: string,
gclientSyncOptions: $ReadOnly<{nohooks: boolean}>,
gclientSyncOptions: Readonly<{nohooks: boolean}>,
gnArgsSummary: string,
noBuild: boolean,
}> */,
@@ -588,7 +588,7 @@ async function createSyncDiff(
{
checkoutPath,
noBuild,
} /*: $ReadOnly<{checkoutPath: string, noBuild: boolean}> */,
} /*: Readonly<{checkoutPath: string, noBuild: boolean}> */,
) {
process.stdout.write('Creating a sync diff\n');
const {packagePath, baseGitRevision} = diffBaseInfo;
+1 -1
View File
@@ -16,7 +16,7 @@ try {
isMetaInternal = false;
}
let additionalConfig /*: $ReadOnly<{
let additionalConfig /*: Readonly<{
appVersionHash: ?string,
}> */ = {
appVersionHash: null,
+1 -1
View File
@@ -15,7 +15,7 @@
function tryExecNTimes(
funcToRetry /*: () => number */,
retriesLeft /*: number */,
onEveryError /*: ?(() => mixed) */,
onEveryError /*: ?(() => unknown) */,
) /*: number */ {
const exitCode = funcToRetry();
if (exitCode === 0) {
+2 -2
View File
@@ -22,8 +22,8 @@ import type { Dependency, Destination, Platform } from './types';
async function buildDepenencies(
scheme /*: string */,
configuration /*: string */,
dependencies /*: $ReadOnlyArray<Dependency> */,
destinations /*: $ReadOnlyArray<Destination> */,
dependencies /*: ReadonlyArray<Dependency> */,
destinations /*: ReadonlyArray<Destination> */,
rootFolder /*: string */,
buildFolder /*: string */,
) {
+3 -3
View File
@@ -17,7 +17,7 @@ import type {Dependency, Destination, Platform} from './types';
// CI can't use commas in cache keys, so 'macOS,variant=Mac Catalyst' was creating troubles
// This map that converts from platforms to valid Xcodebuild destinations.
const platformToDestination /*: $ReadOnly<{|[Platform]: Destination|}> */ = {
const platformToDestination /*: Readonly<{|[Platform]: Destination|}> */ = {
ios: 'iOS',
'ios-simulator': 'iOS Simulator',
macos: 'macOS',
@@ -92,8 +92,8 @@ async function getCLIConfiguration() /*: Promise<?{|
build: boolean,
compose: boolean,
|},
destinations: $ReadOnlyArray<Destination>,
dependencies: $ReadOnlyArray<Dependency>,
destinations: ReadonlyArray<Destination>,
dependencies: ReadonlyArray<Dependency>,
configuration: string,
identity: ?string,
|}> */ {
@@ -23,7 +23,7 @@ import type { Dependency, Platform } from './types';
async function createFramework(
scheme /*: string */,
configuration /*: string */,
dependencies /*: $ReadOnlyArray<Dependency> */,
dependencies /*: ReadonlyArray<Dependency> */,
rootFolder /*: string */,
buildFolder /*: string */,
identity /*: ?string */,
@@ -81,7 +81,7 @@ async function createFramework(
*/
function copyHeaders(
scheme /*: string */,
dependencies /*: $ReadOnlyArray<Dependency> */,
dependencies /*: ReadonlyArray<Dependency> */,
rootFolder /*: string */,
) {
console.log('Copying header files for dependencies...');
@@ -114,7 +114,7 @@ function copyHeaders(
*/
function copyBundles(
scheme /*: string */,
dependencies /*: $ReadOnlyArray<Dependency> */,
dependencies /*: ReadonlyArray<Dependency> */,
outputFolder /*:string*/,
frameworkPaths /*:Array<string>*/,
) {
@@ -12,7 +12,7 @@
import type { Dependency, Platform } from './types';
*/
const platforms /*: $ReadOnlyArray<Platform> */ = [
const platforms /*: ReadonlyArray<Platform> */ = [
'ios',
'ios-simulator',
'macos',
@@ -25,7 +25,7 @@ const platforms /*: $ReadOnlyArray<Platform> */ = [
const CPP_STANDARD = 'c++20';
const dependencies /*: $ReadOnlyArray<Dependency> */ = [
const dependencies /*: ReadonlyArray<Dependency> */ = [
{
name: 'glog',
version: '0.3.5',
@@ -32,7 +32,7 @@ const exec = util.promisify(require('child_process').exec);
* according to the configuration provided.
*/
async function setupDependencies(
dependencies /*: $ReadOnlyArray<Dependency> */,
dependencies /*: ReadonlyArray<Dependency> */,
rootFolder /*: string */,
) {
console.log('✅ Setting up dependencies...');
@@ -21,7 +21,7 @@ const path = require('path');
*/
async function createSwiftPackageFile(
scheme /*: string */,
dependencies /* :$ReadOnlyArray<Dependency> */,
dependencies /* :ReadonlyArray<Dependency> */,
rootFolder /*: string */,
) {
console.log(
+14 -14
View File
@@ -11,10 +11,10 @@
/*::
export type Folder = RegExp;
export type Files = $ReadOnly<{
headers: $ReadOnlyArray<string>,
sources: $ReadOnlyArray<string>,
resources?: $ReadOnlyArray<string>,
export type Files = Readonly<{
headers: ReadonlyArray<string>,
sources: ReadonlyArray<string>,
resources?: ReadonlyArray<string>,
// Relative path from target root to where the header files should be copied.
// Can be used to ensure header search paths like <double-conversion/double-conversion.h>
// are correctly resolved.
@@ -22,22 +22,22 @@ export type Files = $ReadOnly<{
headerSkipFolderNames?: string,
}>;
export type Define = $ReadOnly<{
export type Define = Readonly<{
name: string,
value?: string,
}>;
export type Settings = $ReadOnly<{
headerSearchPaths?: $ReadOnlyArray<string>,
defines?: $ReadOnlyArray<Define>,
cCompilerFlags?: $ReadOnlyArray<string>,
cxxCompilerFlags?: $ReadOnlyArray<string>,
linkedLibraries?: $ReadOnlyArray<string>,
export type Settings = Readonly<{
headerSearchPaths?: ReadonlyArray<string>,
defines?: ReadonlyArray<Define>,
cCompilerFlags?: ReadonlyArray<string>,
cxxCompilerFlags?: ReadonlyArray<string>,
linkedLibraries?: ReadonlyArray<string>,
publicHeaderFiles: string,
linkerSettings?: $ReadOnlyArray<string>
linkerSettings?: ReadonlyArray<string>
}>;
export type Dependency = $ReadOnly<{
export type Dependency = Readonly<{
name: string,
version: string,
url: URL,
@@ -45,7 +45,7 @@ export type Dependency = $ReadOnly<{
files: Files,
settings: Settings,
disabled?: boolean,
dependencies?: $ReadOnlyArray<string>,
dependencies?: ReadonlyArray<string>,
}>;
export type Platform =
@@ -30,15 +30,15 @@ import type {DotSlashProvider, DotSlashHttpProvider, DotSlashArtifactInfo} from
import type {IOctokit} from './utils/octokit-utils';
type GitHubReleaseAsset = {id: string, ...};
type ReleaseAssetMap = $ReadOnlyMap<string, GitHubReleaseAsset>;
type ReleaseAssetMap = ReadonlyMap<string, GitHubReleaseAsset>;
type ReleaseInfo = $ReadOnly<{
type ReleaseInfo = Readonly<{
releaseId: string,
releaseTag: string,
existingAssetsByName: ReleaseAssetMap,
}>;
type ExecutionOptions = $ReadOnly<{
type ExecutionOptions = Readonly<{
force: boolean,
dryRun: boolean,
}>;
@@ -191,7 +191,7 @@ async function fetchUpstreamAssetAndUploadToRelease(
artifactInfo,
dotslashFilename,
} /*: {
providers: $ReadOnlyArray<DotSlashProvider>,
providers: ReadonlyArray<DotSlashProvider>,
suggestedFilename: string,
artifactInfo: DotSlashArtifactInfo,
dotslashFilename: string,
+7 -7
View File
@@ -40,7 +40,7 @@ type DotSlashPlatformSpec = {
...
};
export type DotSlashArtifactInfo = $ReadOnly<{
export type DotSlashArtifactInfo = Readonly<{
size: number,
hash: 'blake3' | 'sha256',
digest: string,
@@ -54,13 +54,13 @@ type JSONCFormattingOptions = {
};
type DotSlashProvidersTransformFn = (
providers: $ReadOnlyArray<DotSlashProvider>,
providers: ReadonlyArray<DotSlashProvider>,
suggestedFilename: string,
artifactInfo: DotSlashArtifactInfo,
) => ?$ReadOnlyArray<DotSlashProvider> | Promise<?$ReadOnlyArray<DotSlashProvider>>;
) => ?ReadonlyArray<DotSlashProvider> | Promise<?ReadonlyArray<DotSlashProvider>>;
*/
const DEFAULT_FORMATTING_OPTIONS /*: $ReadOnly<JSONCFormattingOptions> */ = {
const DEFAULT_FORMATTING_OPTIONS /*: Readonly<JSONCFormattingOptions> */ = {
tabSize: 4,
insertSpaces: true,
eol: '\n',
@@ -75,7 +75,7 @@ const DEFAULT_FORMATTING_OPTIONS /*: $ReadOnly<JSONCFormattingOptions> */ = {
async function processDotSlashFileInPlace(
filename /*: string */,
transformProviders /*: DotSlashProvidersTransformFn */,
formattingOptions /*: $ReadOnly<JSONCFormattingOptions> */ = DEFAULT_FORMATTING_OPTIONS,
formattingOptions /*: Readonly<JSONCFormattingOptions> */ = DEFAULT_FORMATTING_OPTIONS,
) /*: Promise<void> */ {
// Validate the file using `dotslash` itself so we can be reasonably sure that it conforms
// to the expected format.
@@ -87,7 +87,7 @@ async function processDotSlashFileInPlace(
const json = parse(originalContentsJson);
let intermediateContentsJson = originalContentsJson;
for (const [platform, platformSpec] of Object.entries(json.platforms) /*::
as $ReadOnlyArray<[string, DotSlashPlatformSpec]>
as ReadonlyArray<[string, DotSlashPlatformSpec]>
*/) {
const providers = platformSpec.providers;
const suggestedFilename =
@@ -144,7 +144,7 @@ function splitShebangFromContents(
*/
async function validateAndParseDotSlashFile(
filename /*: string */,
) /*: mixed */ {
) /*: unknown */ {
const {stdout} = await execFile(dotslash, ['--', 'parse', filename]);
return JSON.parse(stdout);
}
@@ -99,7 +99,7 @@ async function writeReleaseAssetUrlsToDotSlashFile(
async function updateAndVerifyProviders(
{providers: providersArg, suggestedFilename, artifactInfo, releaseTag} /*:
{providers: $ReadOnlyArray<DotSlashProvider>,
{providers: ReadonlyArray<DotSlashProvider>,
suggestedFilename: string,
artifactInfo: DotSlashArtifactInfo,
releaseTag: string,}
@@ -151,8 +151,8 @@ function createReleaseAssetProvider(
}
function diffProviderArrays(
original /*: $ReadOnlyArray<DotSlashProvider> */,
updated /*: $ReadOnlyArray<DotSlashProvider> */,
original /*: ReadonlyArray<DotSlashProvider> */,
updated /*: ReadonlyArray<DotSlashProvider> */,
) {
return jestDiff(original, updated, {
aAnnotation: 'Original',
+1 -1
View File
@@ -20,7 +20,7 @@
*/
const {execSync} = require('child_process');
const argv /*:$ReadOnly<{
const argv /*:Readonly<{
maxWorkers?: number,
jestBinary?: string,
flowBinary?: string,
+2 -2
View File
@@ -27,7 +27,7 @@ export type PackageJson = {
...
};
type PackagesFilter = $ReadOnly<{
type PackagesFilter = Readonly<{
// Include the main react-native package
includeReactNative: boolean,
@@ -135,7 +135,7 @@ async function parsePackageInfo(
*/
async function updatePackageJson(
{path: packagePath, packageJson} /*: PackageInfo */,
newPackageVersions /*: $ReadOnly<{[string]: string}> */,
newPackageVersions /*: Readonly<{[string]: string}> */,
) /*: Promise<void> */ {
const packageName = packageJson.name;