From 71cf575fc00495a94c5ad1675480f7ffda38e949 Mon Sep 17 00:00:00 2001 From: Gijs Weterings Date: Wed, 18 Oct 2023 05:36:33 -0700 Subject: [PATCH] Flow strictify xplat/js/tools where possible Summary: `cd xplat/js/tools && ../scripts/flow/upgrade_to_flow_strict_local.sh` This script upgrades `flow` annotations to `flow strict-local` as per best practices from https://www.internalfb.com/intern/wiki/Flow/Flow_Strict/ This helps reduce the issues in https://fburl.com/be/mb0nujbc by 151 Reviewed By: yungsters Differential Revision: D50369010 fbshipit-source-id: 7c36518c8e49a14f41c8620ab7f3f0e3766a6054 --- flow-typed/graceful-fs.js | 2 +- flow-typed/node-abort-controller.js | 2 +- flow-typed/npm/strip-ansi_v3.x.x.js | 15 +++++++++++++++ .../metro-cache-key/src/__tests__/index-test.js | 2 +- packages/metro-cache-key/src/index.js | 2 +- .../stores/__tests__/AutoCleanFileStore-test.js | 2 +- .../src/errors/AmbiguousModuleResolutionError.js | 2 +- packages/metro-core/src/index.js | 2 +- .../src/__tests__/terser-issue-1341-test.js | 2 +- .../__tests__/fast-refresh-integration-test.js | 2 +- packages/metro-source-map/src/BundleBuilder.js | 2 +- .../src/GoogleIgnoreListConsumer.js | 2 +- packages/metro/src/Bundler.js | 2 +- packages/metro/src/Bundler/util.js | 2 +- .../DeltaBundler/Serializers/getRamBundleInfo.js | 2 +- .../Serializers/helpers/processModules.js | 2 +- packages/metro/src/DeltaBundler/Transformer.js | 2 +- packages/metro/src/DeltaBundler/Worker.js | 2 +- .../src/IncrementalBundler/GraphNotFoundError.js | 2 +- .../IncrementalBundler/ResourceNotFoundError.js | 2 +- .../IncrementalBundler/RevisionNotFoundError.js | 2 +- .../src/ModuleGraph/worker/JsFileWrapping.js | 2 +- .../src/ModuleGraph/worker/generateImportNames.js | 2 +- packages/metro/src/index.js | 2 +- .../src/integration_tests/__tests__/build-test.js | 2 +- .../integration_tests/basic_bundle/TestBigInt.js | 2 +- packages/metro/src/lib/logToConsole.js | 2 +- packages/metro/src/lib/reporting.js | 2 +- packages/metro/src/node-haste/Module.js | 2 +- packages/metro/src/shared/output/bundle.js | 2 +- scripts/updateBabelFlowLibraryDefinitions.js | 2 +- 31 files changed, 45 insertions(+), 30 deletions(-) create mode 100644 flow-typed/npm/strip-ansi_v3.x.x.js diff --git a/flow-typed/graceful-fs.js b/flow-typed/graceful-fs.js index 754a091150..4dfac9fb1b 100644 --- a/flow-typed/graceful-fs.js +++ b/flow-typed/graceful-fs.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/flow-typed/node-abort-controller.js b/flow-typed/node-abort-controller.js index a498678365..34dd940c0d 100644 --- a/flow-typed/node-abort-controller.js +++ b/flow-typed/node-abort-controller.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/flow-typed/npm/strip-ansi_v3.x.x.js b/flow-typed/npm/strip-ansi_v3.x.x.js new file mode 100644 index 0000000000..711bed70cc --- /dev/null +++ b/flow-typed/npm/strip-ansi_v3.x.x.js @@ -0,0 +1,15 @@ +/** + * (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary. + * + * @flow strict-local + * @format + * @oncall code_indexing + */ + +declare module 'strip-ansi' { + declare module.exports: (string: string) => string; +} + +declare module 'strip-ansi' { + declare export default function stripAnsi(string: string): string; +} diff --git a/packages/metro-cache-key/src/__tests__/index-test.js b/packages/metro-cache-key/src/__tests__/index-test.js index 211b8865b6..dd847d509f 100644 --- a/packages/metro-cache-key/src/__tests__/index-test.js +++ b/packages/metro-cache-key/src/__tests__/index-test.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-cache-key/src/index.js b/packages/metro-cache-key/src/index.js index a4d3ce1be6..d7b8c8d270 100644 --- a/packages/metro-cache-key/src/index.js +++ b/packages/metro-cache-key/src/index.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-cache/src/stores/__tests__/AutoCleanFileStore-test.js b/packages/metro-cache/src/stores/__tests__/AutoCleanFileStore-test.js index f0de0fdcad..87bb6e5e16 100644 --- a/packages/metro-cache/src/stores/__tests__/AutoCleanFileStore-test.js +++ b/packages/metro-cache/src/stores/__tests__/AutoCleanFileStore-test.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-core/src/errors/AmbiguousModuleResolutionError.js b/packages/metro-core/src/errors/AmbiguousModuleResolutionError.js index 761faf6721..4a9d4a37ae 100644 --- a/packages/metro-core/src/errors/AmbiguousModuleResolutionError.js +++ b/packages/metro-core/src/errors/AmbiguousModuleResolutionError.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-core/src/index.js b/packages/metro-core/src/index.js index 23e3d0c512..45cdd92559 100644 --- a/packages/metro-core/src/index.js +++ b/packages/metro-core/src/index.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-minify-terser/src/__tests__/terser-issue-1341-test.js b/packages/metro-minify-terser/src/__tests__/terser-issue-1341-test.js index 52a2120155..27f62238c2 100644 --- a/packages/metro-minify-terser/src/__tests__/terser-issue-1341-test.js +++ b/packages/metro-minify-terser/src/__tests__/terser-issue-1341-test.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/metro-runtime/src/polyfills/__tests__/fast-refresh-integration-test.js b/packages/metro-runtime/src/polyfills/__tests__/fast-refresh-integration-test.js index c05f4547fb..2d2e5c1894 100644 --- a/packages/metro-runtime/src/polyfills/__tests__/fast-refresh-integration-test.js +++ b/packages/metro-runtime/src/polyfills/__tests__/fast-refresh-integration-test.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-source-map/src/BundleBuilder.js b/packages/metro-source-map/src/BundleBuilder.js index b0316bc486..58fc649537 100644 --- a/packages/metro-source-map/src/BundleBuilder.js +++ b/packages/metro-source-map/src/BundleBuilder.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro-symbolicate/src/GoogleIgnoreListConsumer.js b/packages/metro-symbolicate/src/GoogleIgnoreListConsumer.js index e0f28a56fe..9133b91483 100644 --- a/packages/metro-symbolicate/src/GoogleIgnoreListConsumer.js +++ b/packages/metro-symbolicate/src/GoogleIgnoreListConsumer.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/Bundler.js b/packages/metro/src/Bundler.js index e38abe006d..80bad14167 100644 --- a/packages/metro/src/Bundler.js +++ b/packages/metro/src/Bundler.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/Bundler/util.js b/packages/metro/src/Bundler/util.js index 0641082089..35cec0c810 100644 --- a/packages/metro/src/Bundler/util.js +++ b/packages/metro/src/Bundler/util.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/DeltaBundler/Serializers/getRamBundleInfo.js b/packages/metro/src/DeltaBundler/Serializers/getRamBundleInfo.js index fd9cd667a5..2fd9e6b93a 100644 --- a/packages/metro/src/DeltaBundler/Serializers/getRamBundleInfo.js +++ b/packages/metro/src/DeltaBundler/Serializers/getRamBundleInfo.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/DeltaBundler/Serializers/helpers/processModules.js b/packages/metro/src/DeltaBundler/Serializers/helpers/processModules.js index 1318875ea6..4aaabd0659 100644 --- a/packages/metro/src/DeltaBundler/Serializers/helpers/processModules.js +++ b/packages/metro/src/DeltaBundler/Serializers/helpers/processModules.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/DeltaBundler/Transformer.js b/packages/metro/src/DeltaBundler/Transformer.js index 65cbbc58d3..f208f51ba7 100644 --- a/packages/metro/src/DeltaBundler/Transformer.js +++ b/packages/metro/src/DeltaBundler/Transformer.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/DeltaBundler/Worker.js b/packages/metro/src/DeltaBundler/Worker.js index 266e0a92b9..3b5718dbc8 100644 --- a/packages/metro/src/DeltaBundler/Worker.js +++ b/packages/metro/src/DeltaBundler/Worker.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/IncrementalBundler/GraphNotFoundError.js b/packages/metro/src/IncrementalBundler/GraphNotFoundError.js index f4543c1795..bb31560232 100644 --- a/packages/metro/src/IncrementalBundler/GraphNotFoundError.js +++ b/packages/metro/src/IncrementalBundler/GraphNotFoundError.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/IncrementalBundler/ResourceNotFoundError.js b/packages/metro/src/IncrementalBundler/ResourceNotFoundError.js index 83e31820aa..c55b8c3d9c 100644 --- a/packages/metro/src/IncrementalBundler/ResourceNotFoundError.js +++ b/packages/metro/src/IncrementalBundler/ResourceNotFoundError.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/IncrementalBundler/RevisionNotFoundError.js b/packages/metro/src/IncrementalBundler/RevisionNotFoundError.js index 4bfd7b122a..04f48ef0b7 100644 --- a/packages/metro/src/IncrementalBundler/RevisionNotFoundError.js +++ b/packages/metro/src/IncrementalBundler/RevisionNotFoundError.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/ModuleGraph/worker/JsFileWrapping.js b/packages/metro/src/ModuleGraph/worker/JsFileWrapping.js index 454c6cde89..e06213eeda 100644 --- a/packages/metro/src/ModuleGraph/worker/JsFileWrapping.js +++ b/packages/metro/src/ModuleGraph/worker/JsFileWrapping.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict-local */ 'use strict'; diff --git a/packages/metro/src/ModuleGraph/worker/generateImportNames.js b/packages/metro/src/ModuleGraph/worker/generateImportNames.js index ff6fab9383..b539084460 100644 --- a/packages/metro/src/ModuleGraph/worker/generateImportNames.js +++ b/packages/metro/src/ModuleGraph/worker/generateImportNames.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict-local */ 'use strict'; diff --git a/packages/metro/src/index.js b/packages/metro/src/index.js index b3f8435706..47a8753481 100644 --- a/packages/metro/src/index.js +++ b/packages/metro/src/index.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/integration_tests/__tests__/build-test.js b/packages/metro/src/integration_tests/__tests__/build-test.js index b41b8d8b5d..2f660cc365 100644 --- a/packages/metro/src/integration_tests/__tests__/build-test.js +++ b/packages/metro/src/integration_tests/__tests__/build-test.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/integration_tests/basic_bundle/TestBigInt.js b/packages/metro/src/integration_tests/basic_bundle/TestBigInt.js index 8cf060e680..70c4b66891 100644 --- a/packages/metro/src/integration_tests/basic_bundle/TestBigInt.js +++ b/packages/metro/src/integration_tests/basic_bundle/TestBigInt.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict-local */ 'use strict'; diff --git a/packages/metro/src/lib/logToConsole.js b/packages/metro/src/lib/logToConsole.js index 44a16f8ff0..fe37e47cf1 100644 --- a/packages/metro/src/lib/logToConsole.js +++ b/packages/metro/src/lib/logToConsole.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict-local */ /* eslint-disable no-console */ diff --git a/packages/metro/src/lib/reporting.js b/packages/metro/src/lib/reporting.js index 40a22ddbdd..5ee1e0f0d1 100644 --- a/packages/metro/src/lib/reporting.js +++ b/packages/metro/src/lib/reporting.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/node-haste/Module.js b/packages/metro/src/node-haste/Module.js index b0325d14dc..2bcc29f95f 100644 --- a/packages/metro/src/node-haste/Module.js +++ b/packages/metro/src/node-haste/Module.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/packages/metro/src/shared/output/bundle.js b/packages/metro/src/shared/output/bundle.js index 390f9ef986..fd214f16cb 100644 --- a/packages/metro/src/shared/output/bundle.js +++ b/packages/metro/src/shared/output/bundle.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @oncall react_native */ diff --git a/scripts/updateBabelFlowLibraryDefinitions.js b/scripts/updateBabelFlowLibraryDefinitions.js index 3d9a22526b..f0b9c06f18 100644 --- a/scripts/updateBabelFlowLibraryDefinitions.js +++ b/scripts/updateBabelFlowLibraryDefinitions.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @format - * @flow + * @flow strict-local * @oncall react_native */