Skip to content

Commit

Permalink
Add missing type objectFit prop in image style type definition (#36249)
Browse files Browse the repository at this point in the history
Summary:
Following the [`initial commit`](b2452ab), the `objectFit` property have been implemented. However, it is not declared in the Typescript type files, making it unknown to the typescript compiler. Thus, when using this property in Typescript, we have the following issue:

![Capture d’écran 2023-02-22 à 14 52 04](https://user-images.githubusercontent.com/29439916/220639885-947dddb1-5e6f-4f60-b423-882ade29ac5a.png)

Then, the purpose of this PR is to fix that by adding the missing property to the `ImageStyle` interface defined in the`StyleSheetTypes.d.ts` file.

## Changelog

[GENERAL][FIXED] Add objectFit to the ImageStyle interface located in the StyleSheetTypes.d.ts file

Pull Request resolved: #36249

Test Plan:
To test it, create/use a typescript file and call the `Image` component with a `style` property. Then, check if the autocompletion provides you the right properties with the right type. For example:

![Capture d’écran 2023-02-22 à 14 34 58](https://user-images.githubusercontent.com/29439916/220636819-4c0d80dc-bc3a-468d-bcfc-782e038918ca.png)
![Capture d’écran 2023-02-22 à 14 35 46](https://user-images.githubusercontent.com/29439916/220636863-76a84122-0cdb-4d5d-8edf-309ed7c876f7.png)

Reviewed By: NickGerleman, rshest

Differential Revision: D43665291

Pulled By: motiz88

fbshipit-source-id: bf136b8aeb9dd25ff0e696b747ef5805acf8028c
  • Loading branch information
alvessteve authored and facebook-github-bot committed Feb 28, 2023
1 parent d504fb4 commit 32d03c2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/StyleSheet/StyleSheetTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,5 @@ export interface ImageStyle extends FlexStyle, ShadowStyleIOS, TransformsStyle {
overlayColor?: ColorValue | undefined;
tintColor?: ColorValue | undefined;
opacity?: number | undefined;
objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down' | undefined;
}

0 comments on commit 32d03c2

Please sign in to comment.