From 65f373b0848ed37609c466d39668a35ae2785de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Sl=C3=A1vik?= Date: Fri, 21 Oct 2022 14:43:37 +0200 Subject: [PATCH] fix: [types] allow Image "href" & "xlinkHref" to be strings (#1896) Allow 'string' type for href and xlinkHref props in Image component. Logic in the component allows passing 'string' values to the Image.resolveAssetSource by checking for its type, so it would be nice to reflect it on the properties types as well. --- Example/src/examples/Image.tsx | 1 - FabricExample/src/examples/Image.tsx | 1 - src/elements/Image.tsx | 4 ++-- src/index.js.flow | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Example/src/examples/Image.tsx b/Example/src/examples/Image.tsx index 6af4a70e..27f7b701 100644 --- a/Example/src/examples/Image.tsx +++ b/Example/src/examples/Image.tsx @@ -82,7 +82,6 @@ class DataURI extends Component { y="5%" width="90%" height="90%" - // @ts-expect-error href={Platform.OS === 'web' ? dataUriExample : {uri: dataUriExample}} opacity="0.6" /> diff --git a/FabricExample/src/examples/Image.tsx b/FabricExample/src/examples/Image.tsx index d0b8c6f3..8ded8cd1 100644 --- a/FabricExample/src/examples/Image.tsx +++ b/FabricExample/src/examples/Image.tsx @@ -82,7 +82,6 @@ class DataURI extends Component { y="5%" width="90%" height="90%" - // @ts-expect-error href={Platform.OS === 'web' ? dataUriExample : {uri: dataUriExample}} opacity="0.6" /> diff --git a/src/elements/Image.tsx b/src/elements/Image.tsx index bb1b1994..d5cece10 100644 --- a/src/elements/Image.tsx +++ b/src/elements/Image.tsx @@ -28,8 +28,8 @@ export interface ImageProps y?: NumberProp; width?: NumberProp; height?: NumberProp; - xlinkHref?: RNImageProps['source']; - href?: RNImageProps['source']; + xlinkHref?: RNImageProps['source'] | string; + href?: RNImageProps['source'] | string; preserveAspectRatio?: string; opacity?: NumberProp; clipPath?: string; diff --git a/src/index.js.flow b/src/index.js.flow index 0550ba5b..76eead2c 100644 --- a/src/index.js.flow +++ b/src/index.js.flow @@ -252,8 +252,8 @@ export type ImageProps = { y?: NumberProp, width?: NumberProp, height?: NumberProp, - xlinkHref?: $PropertyType, - href?: $PropertyType, + xlinkHref?: $PropertyType | string, + href?: $PropertyType | string, preserveAspectRatio?: string, opacity?: NumberProp, clipPath?: string,