Skip to content

Commit

Permalink
Missing src, srcSet, referrerPolicy, tintColor on Image.d.ts (#36214)
Browse files Browse the repository at this point in the history
Summary:
After reviewing the doc [`Image`](https://reactnative.dev/docs/image), the typescript compiler doesn't know the following properties:
- src
- srcSet
- referrerPolicy
- tintColor
- objectFit

But after reviewing the source code and this [`commit`](b2452ab), the `objectFit` property isn't one related to the Image component but to the `style` props, making the official doc outdated. So, an [`issue in the react-native-website repo`](facebook/react-native-website#3579) have been created and I decided to not include the objectFit prop in this PR.

So, this PR includes those properties: sec, secSet, referrerPolicy and tintColor

## Changelog

[GENERAL][FIXED] Add src, srcSet, referrerPolicy, tintColor to Image.d.ts declaration file

Pull Request resolved: #36214

Reviewed By: NickGerleman

Differential Revision: D43437894

Pulled By: rshest

fbshipit-source-id: 497426490134aba0a474c49bf8bab9131f2e5845
  • Loading branch information
alvessteve authored and facebook-github-bot committed Feb 23, 2023
1 parent c5bc3f1 commit 74cb607
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion Libraries/Image/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {Constructor} from '../../types/private/Utilities';
import {AccessibilityProps} from '../Components/View/ViewAccessibility';
import {Insets} from '../../types/public/Insets';
import {NativeMethods} from '../../types/public/ReactNativeTypes';
import {StyleProp} from '../StyleSheet/StyleSheet';
import {ColorValue, StyleProp} from '../StyleSheet/StyleSheet';
import {ImageStyle, ViewStyle} from '../StyleSheet/StyleSheetTypes';
import {LayoutChangeEvent, NativeSyntheticEvent} from '../Types/CoreEventTypes';
import {ImageResizeMode} from './ImageResizeMode';
Expand Down Expand Up @@ -225,6 +225,21 @@ export interface ImagePropsBase
*/
source: ImageSourcePropType;

/**
* A string representing the resource identifier for the image. Similar to
* src from HTML.
*
* See https://reactnative.dev/docs/image#src
*/
src?: string | undefined;

/**
* Similar to srcset from HTML.
*
* See https://reactnative.dev/docs/image#srcset
*/
srcSet?: string | undefined;

/**
* similarly to `source`, this property represents the resource used to render
* the loading indicator for the image, displayed until image is ready to be
Expand Down Expand Up @@ -276,6 +291,30 @@ export interface ImagePropsBase
* See https://reactnative.dev/docs/image#crossorigin
*/
crossOrigin?: 'anonymous' | 'use-credentials';

/**
* Changes the color of all the non-transparent pixels to the tintColor.
*
* See https://reactnative.dev/docs/image#tintcolor
*/
tintColor?: ColorValue | undefined;

/**
* A string indicating which referrer to use when fetching the resource.
* Similar to referrerpolicy from HTML.
*
* See https://reactnative.dev/docs/image#referrerpolicy
*/
referrerPolicy?:
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url'
| undefined;
}

export interface ImageProps extends ImagePropsBase {
Expand Down

0 comments on commit 74cb607

Please sign in to comment.