From 46c38d14c095b3ab8b11df051f0ee374883cb632 Mon Sep 17 00:00:00 2001 From: Thorr Stevens Date: Tue, 9 Apr 2024 18:24:05 +0200 Subject: [PATCH 1/3] fix: Remove Flow from @react-native/assets-registry's registry.js ## React native shipping Flow types breaks universal apps See: https://github.com/expo/expo/issues/21623#issuecomment-1492180436 https://github.com/expo/expo/issues/21623#issuecomment-1640395262 https://github.com/expo/expo/issues/21469#issuecomment-1879873320 --- packages/assets/registry.js | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/packages/assets/registry.js b/packages/assets/registry.js index 02470da3c496..a91800fed4d0 100644 --- a/packages/assets/registry.js +++ b/packages/assets/registry.js @@ -4,34 +4,20 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow strict * @format */ 'use strict'; -export type PackagerAsset = { - +__packager_asset: boolean, - +fileSystemLocation: string, - +httpServerLocation: string, - +width: ?number, - +height: ?number, - +scales: Array, - +hash: string, - +name: string, - +type: string, - ... -}; +const assets = []; -const assets: Array = []; - -function registerAsset(asset: PackagerAsset): number { +function registerAsset(asset) { // `push` returns new array length, so the first asset will // get id 1 (not 0) to make the value truthy return assets.push(asset); } -function getAssetByID(assetId: number): PackagerAsset { +function getAssetByID(assetId) { return assets[assetId - 1]; } From 66299a0dd13041e53c82087ef9c6e06dc497b681 Mon Sep 17 00:00:00 2001 From: Thorr Stevens Date: Tue, 9 Apr 2024 19:05:38 +0200 Subject: [PATCH 2/3] Update registry.js Add `@flow` comment to run automatic tests accurately --- packages/assets/registry.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/assets/registry.js b/packages/assets/registry.js index a91800fed4d0..f211d2cc2f97 100644 --- a/packages/assets/registry.js +++ b/packages/assets/registry.js @@ -4,6 +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 * @format */ From 63be0b5b5a077afe7a731172d417ca93e8d67f3c Mon Sep 17 00:00:00 2001 From: Thorr Stevens Date: Tue, 9 Apr 2024 19:12:05 +0200 Subject: [PATCH 3/3] Update assets/registry.js to @flow noflow --- packages/assets/registry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/assets/registry.js b/packages/assets/registry.js index f211d2cc2f97..0510304b9473 100644 --- a/packages/assets/registry.js +++ b/packages/assets/registry.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 noflow * @format */