4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
6
6
*
7
- * @flow
7
+ * @flow strict
8
8
* @format
9
9
*/
10
10
11
11
'use strict' ;
12
12
13
- // This is to sync with ImageSourcePropTypes.js.
14
- // We explicitly don't want this to be strict so that we can pass in objects
15
- // that might have more keys. This also has to be inexact to support taking
16
- // instances of classes like FBIcon.
17
- // https://fburl.com/8lynhvtw
13
+ /**
14
+ * Keep this in sync with `DeprecatedImageSourcePropType.js`.
15
+ *
16
+ * This type is intentinoally inexact in order to permit call sites that supply
17
+ * extra properties.
18
+ */
18
19
export type ImageURISource = $ReadOnly < {
19
20
/**
20
21
* `uri` is a string representing the resource identifier for the image, which
@@ -23,27 +24,32 @@ export type ImageURISource = $ReadOnly<{
23
24
* function).
24
25
*/
25
26
uri ?: ?string ,
27
+
26
28
/**
27
29
* `bundle` is the iOS asset bundle which the image is included in. This
28
30
* will default to [NSBundle mainBundle] if not set.
29
31
* @platform ios
30
32
*/
31
33
bundle ?: ?string ,
34
+
32
35
/**
33
36
* `method` is the HTTP Method to use. Defaults to GET if not specified.
34
37
*/
35
38
method ?: ?string ,
39
+
36
40
/**
37
41
* `headers` is an object representing the HTTP headers to send along with the
38
42
* request for a remote image.
39
43
*/
40
- headers ?: ?Object ,
44
+ headers ?: ?{ [ string ] : string } ,
45
+
41
46
/**
42
47
* `body` is the HTTP body to send with the request. This must be a valid
43
48
* UTF-8 string, and will be sent exactly as specified, with no
44
49
* additional encoding (e.g. URL-escaping or base64) applied.
45
50
*/
46
51
body ?: ?string ,
52
+
47
53
/**
48
54
* `cache` determines how the requests handles potentially cached
49
55
* responses.
@@ -65,21 +71,24 @@ export type ImageURISource = $ReadOnly<{
65
71
* @platform ios
66
72
*/
67
73
cache ?: ?( 'default' | 'reload' | 'force-cache' | 'only-if-cached' ) ,
74
+
68
75
/**
69
76
* `width` and `height` can be specified if known at build time, in which case
70
77
* these will be used to set the default `<Image/>` component dimensions.
71
78
*/
72
79
width ?: ?number ,
73
80
height ?: ?number ,
81
+
74
82
/**
75
83
* `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if
76
84
* unspecified, meaning that one image pixel equates to one display point / DIP.
77
85
*/
78
86
scale ?: ?number ,
87
+
79
88
...
80
89
} > ;
81
90
82
- // We have to export any because of an issue in Flow with objects that come from Relay:
83
- // https://fburl.com/8ljo5tmr
84
- // https://fb.facebook.com/groups/flow/permalink/1824103160971624/
85
- export type ImageSource = ImageURISource | number | Array < ImageURISource > ;
91
+ export type ImageSource =
92
+ | number
93
+ | ImageURISource
94
+ | $ReadOnlyArray < ImageURISource > ;
0 commit comments