From 74cb6073f3ae926de712d883d08eb19ed2339788 Mon Sep 17 00:00:00 2001 From: Steve Alves-Blyt Date: Wed, 22 Feb 2023 16:14:39 -0800 Subject: [PATCH] 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`](https://github.com/facebook/react-native/commit/b2452ab216e28e004dc625dd8e1ad32351a79be9), 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`](https://github.com/facebook/react-native-website/issues/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: https://github.com/facebook/react-native/pull/36214 Reviewed By: NickGerleman Differential Revision: D43437894 Pulled By: rshest fbshipit-source-id: 497426490134aba0a474c49bf8bab9131f2e5845 --- Libraries/Image/Image.d.ts | 41 +++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Libraries/Image/Image.d.ts b/Libraries/Image/Image.d.ts index 3391ad1f93a265..e650c11fd2aca2 100644 --- a/Libraries/Image/Image.d.ts +++ b/Libraries/Image/Image.d.ts @@ -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'; @@ -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 @@ -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 {