Skip to content

Commit

Permalink
refactor(image typing): use ImageRequireSource instead of number for …
Browse files Browse the repository at this point in the history
…defaultSource prop typing (#40801)

Summary:
This is just a type refactoring to make the typing of the `defaultSource` prop of the Image component more explicit and descriptive (using the `ImageRequireSource` type makes it more clear that we can use the require statement to set an image asset as default source) and this is also more consistent with the `source` prop typing.

Currently :
- The typing of default source is `ImageURISource | number | undefined`
- The typing of source is `ImageSourcePropType` which is equal to `ImageURISource  | ImageURISource[]  | ImageRequireSource` and `ImageRequireSource` is equal to `number`.

In this PR we change the typing of default source to `ImageURISource | ImageRequireSource | undefined` to make more clear that the number of the default source prop refers to the use of the require statement with an asset file.

## Changelog:
[GENERAL] [CHANGED] - use ImageRequireSource instead of number for the defaultSource prop typing of the Image component

Pull Request resolved: #40801

Test Plan: No one required since it's a small typing refactoring.

Reviewed By: christophpurrer

Differential Revision: D50209922

Pulled By: NickGerleman

fbshipit-source-id: c25f3c6f145f357ff1cb0b1c7b54a19bf1dec824
  • Loading branch information
ellouzeskandercs authored and facebook-github-bot committed Oct 12, 2023
1 parent 5217890 commit 2be1c71
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Image/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export interface ImagePropsBase
/**
* A static image to display while downloading the final image off the network.
*/
defaultSource?: ImageURISource | number | undefined;
defaultSource?: ImageURISource | ImageRequireSource | undefined;

/**
* The text that's read by the screen reader when the user interacts with
Expand Down

0 comments on commit 2be1c71

Please sign in to comment.