diff --git a/packages/react-native/Libraries/Image/ImageTypes.flow.js b/packages/react-native/Libraries/Image/ImageTypes.flow.js index 863b67f21710..0b0307dd7666 100644 --- a/packages/react-native/Libraries/Image/ImageTypes.flow.js +++ b/packages/react-native/Libraries/Image/ImageTypes.flow.js @@ -25,6 +25,11 @@ export type ImageSize = { export type ImageResolvedAssetSource = ResolvedAssetSource; +// Declared outside the object type below so that the generated TypeScript keeps +// `null`: `?T` on an object member is translated to `T | undefined`, while +// `resolveAssetSource` returns `null` for an asset that isn't registered. +type ResolveAssetSourceResult = ?ImageResolvedAssetSource; + type ImageComponentStaticsIOS = Readonly<{ getSize(uri: string): Promise, getSize( @@ -59,7 +64,7 @@ type ImageComponentStaticsIOS = Readonly<{ /** * @see https://reactnative.dev/docs/image#resolveassetsource */ - resolveAssetSource(source: ImageSource): ?ImageResolvedAssetSource, + resolveAssetSource(source: ImageSource): ResolveAssetSourceResult, }>; type ImageComponentStaticsAndroid = Readonly<{ diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index 11a5302585ba..12d274e302ee 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -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. * - * @generated SignedSource<<59570f49ad456d1306656541407d4293>> + * @generated SignedSource<<29631535ce4a01eecb50e46dbc089112>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -2461,7 +2461,7 @@ declare type ImageComponentStaticsIOS = { queryCache(urls: Array): Promise<{ [url: string]: "disk" | "disk/memory" | "memory" }> - resolveAssetSource(source: ImageSource): ImageResolvedAssetSource | undefined + resolveAssetSource(source: ImageSource): ResolveAssetSourceResult } declare type ImageErrorEvent = NativeSyntheticEvent< Readonly @@ -4111,6 +4111,8 @@ declare type RequiredVirtualizedSectionListProps< sections: ReadonlyArray> } declare type requireNativeComponent = typeof requireNativeComponent +declare type ResolveAssetSourceResult = + ImageResolvedAssetSource | null | undefined declare type ResolvedAssetSource = { readonly height: number | undefined readonly scale: number @@ -5783,9 +5785,9 @@ export { AlertOptions, // 8a116d2a AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // ab3b6335 + Animated, // 2777dffd AnimatedFlatList, // 8a120aa8 - AnimatedImage, // 91126d6f + AnimatedImage, // ee18295c AnimatedScrollView, // 5a621f5a AnimatedSectionList, // eeb7442a AnimatedText, // c710a0a7 @@ -5853,10 +5855,10 @@ export { IEventEmitter, // fbef6131 IOSKeyboardEvent, // e67bfe3a IgnorePattern, // ec6f6ece - Image, // 9aebdb1b - ImageBackground, // d197b60d - ImageBackgroundInstance, // 2e7c380e - ImageBackgroundProps, // 910aaf4a + Image, // 55e477a7 + ImageBackground, // fc38b895 + ImageBackgroundInstance, // 38a966fa + ImageBackgroundProps, // 4c5e22f3 ImageErrorEvent, // b6227714 ImageInstance, // df709524 ImageLoadEvent, // 31709c38