Skip to content

Commit 74cb607

Browse files
alvesstevefacebook-github-bot
authored andcommitted
Missing src, srcSet, referrerPolicy, tintColor on Image.d.ts (#36214)
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
1 parent c5bc3f1 commit 74cb607

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

Libraries/Image/Image.d.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {Constructor} from '../../types/private/Utilities';
1212
import {AccessibilityProps} from '../Components/View/ViewAccessibility';
1313
import {Insets} from '../../types/public/Insets';
1414
import {NativeMethods} from '../../types/public/ReactNativeTypes';
15-
import {StyleProp} from '../StyleSheet/StyleSheet';
15+
import {ColorValue, StyleProp} from '../StyleSheet/StyleSheet';
1616
import {ImageStyle, ViewStyle} from '../StyleSheet/StyleSheetTypes';
1717
import {LayoutChangeEvent, NativeSyntheticEvent} from '../Types/CoreEventTypes';
1818
import {ImageResizeMode} from './ImageResizeMode';
@@ -225,6 +225,21 @@ export interface ImagePropsBase
225225
*/
226226
source: ImageSourcePropType;
227227

228+
/**
229+
* A string representing the resource identifier for the image. Similar to
230+
* src from HTML.
231+
*
232+
* See https://reactnative.dev/docs/image#src
233+
*/
234+
src?: string | undefined;
235+
236+
/**
237+
* Similar to srcset from HTML.
238+
*
239+
* See https://reactnative.dev/docs/image#srcset
240+
*/
241+
srcSet?: string | undefined;
242+
228243
/**
229244
* similarly to `source`, this property represents the resource used to render
230245
* the loading indicator for the image, displayed until image is ready to be
@@ -276,6 +291,30 @@ export interface ImagePropsBase
276291
* See https://reactnative.dev/docs/image#crossorigin
277292
*/
278293
crossOrigin?: 'anonymous' | 'use-credentials';
294+
295+
/**
296+
* Changes the color of all the non-transparent pixels to the tintColor.
297+
*
298+
* See https://reactnative.dev/docs/image#tintcolor
299+
*/
300+
tintColor?: ColorValue | undefined;
301+
302+
/**
303+
* A string indicating which referrer to use when fetching the resource.
304+
* Similar to referrerpolicy from HTML.
305+
*
306+
* See https://reactnative.dev/docs/image#referrerpolicy
307+
*/
308+
referrerPolicy?:
309+
| 'no-referrer'
310+
| 'no-referrer-when-downgrade'
311+
| 'origin'
312+
| 'origin-when-cross-origin'
313+
| 'same-origin'
314+
| 'strict-origin'
315+
| 'strict-origin-when-cross-origin'
316+
| 'unsafe-url'
317+
| undefined;
279318
}
280319

281320
export interface ImageProps extends ImagePropsBase {

0 commit comments

Comments
 (0)