diff --git a/Libraries/Image/ImageSource.js b/Libraries/Image/ImageSource.js index e2f280f66a0395..b2ee46baa1b1d5 100644 --- a/Libraries/Image/ImageSource.js +++ b/Libraries/Image/ImageSource.js @@ -4,17 +4,18 @@ * 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 * @format */ 'use strict'; -// This is to sync with ImageSourcePropTypes.js. -// We explicitly don't want this to be strict so that we can pass in objects -// that might have more keys. This also has to be inexact to support taking -// instances of classes like FBIcon. -// https://fburl.com/8lynhvtw +/** + * Keep this in sync with `DeprecatedImageSourcePropType.js`. + * + * This type is intentinoally inexact in order to permit call sites that supply + * extra properties. + */ export type ImageURISource = $ReadOnly<{ /** * `uri` is a string representing the resource identifier for the image, which @@ -23,27 +24,32 @@ export type ImageURISource = $ReadOnly<{ * function). */ uri?: ?string, + /** * `bundle` is the iOS asset bundle which the image is included in. This * will default to [NSBundle mainBundle] if not set. * @platform ios */ bundle?: ?string, + /** * `method` is the HTTP Method to use. Defaults to GET if not specified. */ method?: ?string, + /** * `headers` is an object representing the HTTP headers to send along with the * request for a remote image. */ - headers?: ?Object, + headers?: ?{[string]: string}, + /** * `body` is the HTTP body to send with the request. This must be a valid * UTF-8 string, and will be sent exactly as specified, with no * additional encoding (e.g. URL-escaping or base64) applied. */ body?: ?string, + /** * `cache` determines how the requests handles potentially cached * responses. @@ -65,21 +71,24 @@ export type ImageURISource = $ReadOnly<{ * @platform ios */ cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'), + /** * `width` and `height` can be specified if known at build time, in which case * these will be used to set the default `` component dimensions. */ width?: ?number, height?: ?number, + /** * `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if * unspecified, meaning that one image pixel equates to one display point / DIP. */ scale?: ?number, + ... }>; -// We have to export any because of an issue in Flow with objects that come from Relay: -// https://fburl.com/8ljo5tmr -// https://fb.facebook.com/groups/flow/permalink/1824103160971624/ -export type ImageSource = ImageURISource | number | Array; +export type ImageSource = + | number + | ImageURISource + | $ReadOnlyArray;