Skip to content

Commit 8924639

Browse files
yungstersfacebook-github-bot
authored andcommitted
RN: Improve nativeImageSource Return Type
Summary: Now that `ImageURISource` is a proper type, `nativeImageSource`'s return type should simply use that instead of being an untyped `Object`. Reviewed By: cpojer Differential Revision: D17246527 fbshipit-source-id: 6ec0c80a93b8794e6c243154875e3560ddacbc59
1 parent 1c2671c commit 8924639

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

Libraries/Image/nativeImageSource.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,20 @@
1010

1111
'use strict';
1212

13-
const Platform = require('../Utilities/Platform');
13+
import Platform from '../Utilities/Platform';
1414

15-
// TODO: Change `nativeImageSource` to return this type.
16-
export type NativeImageSource = {|
17-
+deprecated: true,
18-
+height: number,
19-
+uri: string,
20-
+width: number,
21-
|};
15+
import type {ImageURISource} from './ImageSource';
2216

23-
type NativeImageSourceSpec = {|
24-
+android?: string,
25-
+ios?: string,
26-
+default?: string,
17+
type NativeImageSourceSpec = $ReadOnly<{|
18+
android?: string,
19+
ios?: string,
20+
default?: string,
2721

2822
// For more details on width and height, see
2923
// http://facebook.github.io/react-native/docs/images.html#why-not-automatically-size-everything
30-
+height: number,
31-
+width: number,
32-
|};
24+
height: number,
25+
width: number,
26+
|}>;
3327

3428
/**
3529
* In hybrid apps, use `nativeImageSource` to access images that are already
@@ -47,7 +41,7 @@ type NativeImageSourceSpec = {|
4741
* http://facebook.github.io/react-native/docs/images.html
4842
*
4943
*/
50-
function nativeImageSource(spec: NativeImageSourceSpec): Object {
44+
function nativeImageSource(spec: NativeImageSourceSpec): ImageURISource {
5145
let uri = Platform.select({
5246
android: spec.android,
5347
default: spec.default,

0 commit comments

Comments
 (0)