Skip to content

Commit

Permalink
RN: Improve nativeImageSource Return Type
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 9, 2019
1 parent 1c2671c commit 8924639
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions Libraries/Image/nativeImageSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,20 @@

'use strict';

const Platform = require('../Utilities/Platform');
import Platform from '../Utilities/Platform';

// TODO: Change `nativeImageSource` to return this type.
export type NativeImageSource = {|
+deprecated: true,
+height: number,
+uri: string,
+width: number,
|};
import type {ImageURISource} from './ImageSource';

type NativeImageSourceSpec = {|
+android?: string,
+ios?: string,
+default?: string,
type NativeImageSourceSpec = $ReadOnly<{|
android?: string,
ios?: string,
default?: string,

// For more details on width and height, see
// http://facebook.github.io/react-native/docs/images.html#why-not-automatically-size-everything
+height: number,
+width: number,
|};
height: number,
width: number,
|}>;

/**
* In hybrid apps, use `nativeImageSource` to access images that are already
Expand All @@ -47,7 +41,7 @@ type NativeImageSourceSpec = {|
* http://facebook.github.io/react-native/docs/images.html
*
*/
function nativeImageSource(spec: NativeImageSourceSpec): Object {
function nativeImageSource(spec: NativeImageSourceSpec): ImageURISource {
let uri = Platform.select({
android: spec.android,
default: spec.default,
Expand Down

0 comments on commit 8924639

Please sign in to comment.