Skip to content

Align ImageStyle overflow prop type and compose function type#51285

Closed
coado wants to merge 1 commit into
facebook:mainfrom
coado:export-D74574293
Closed

Align ImageStyle overflow prop type and compose function type#51285
coado wants to merge 1 commit into
facebook:mainfrom
coado:export-D74574293

Conversation

@coado
Copy link
Copy Markdown
Contributor

@coado coado commented May 13, 2025

Summary:
The composeStyles function should correctly determine the type of the input styles (ViewStyle, ImageStyle, TextStyle) base on the output type:

const combinedStyle8: StyleProp<ImageStyle> = StyleSheet.compose(
  // ts-expect-error
  composeTextStyle,
  composeTextStyle,
);

This diff adds generic type checking for compose function and fixes ImageStyle overflow prop type which accepted scroll property (which wasn't previously accepted in manual types) and which enables type system to distinguish ImageStyle from ViewStyle and TextStyle:

previous:

overflow?: 'visible' | 'hidden' | 'scroll'

current:

overflow?: 'visible' | 'hidden'

Changelog:
[Internal]

Differential Revision: D74574293

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Software Mansion Partner: Software Mansion Partner p: Facebook Partner: Facebook labels May 13, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D74574293

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D74574293

@coado coado force-pushed the export-D74574293 branch 2 times, most recently from 23a1bc2 to 9146f94 Compare May 14, 2025 12:13
…ok#51285)

Summary:
Pull Request resolved: facebook#51285

The `composeStyles` function should correctly determine the type of the input styles (`ViewStyle`, `ImageStyle`, `TextStyle`) base on the output type:

```ts
const combinedStyle8: StyleProp<ImageStyle> = StyleSheet.compose(
  // ts-expect-error
  composeTextStyle,
  composeTextStyle,
);
```

This diff adds generic type checking for `compose` function and fixes `ImageStyle` overflow prop type which accepted `scroll` property (which wasn't previously accepted in manual types) and which enables type system to distinguish `ImageStyle` from `ViewStyle` and `TextStyle`:

previous:
```ts
overflow?: 'visible' | 'hidden' | 'scroll'
```

current:
```t
overflow?: 'visible' | 'hidden'
```

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D74574293
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D74574293

@coado coado force-pushed the export-D74574293 branch from 9146f94 to 4c9f398 Compare May 14, 2025 12:17
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 14, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in 4d0f2b2.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @coado in 4d0f2b2

When will my fix make it into a release? | How to file a pick request?

react-native-bot pushed a commit that referenced this pull request May 19, 2025
Summary:
Pull Request resolved: #51285

The `composeStyles` function should correctly determine the type of the input styles (`ViewStyle`, `ImageStyle`, `TextStyle`) base on the output type:

```ts
const combinedStyle8: StyleProp<ImageStyle> = StyleSheet.compose(
  // ts-expect-error
  composeTextStyle,
  composeTextStyle,
);
```

This diff adds generic type checking for `compose` function and fixes `ImageStyle` overflow prop type which accepted `scroll` property (which wasn't previously accepted in manual types) and which enables type system to distinguish `ImageStyle` from `ViewStyle` and `TextStyle`:

previous:
```ts
overflow?: 'visible' | 'hidden' | 'scroll'
```

current:
```t
overflow?: 'visible' | 'hidden'
```

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D74574293

fbshipit-source-id: 751a44f2d3cd43055d93031343995f16ef87b185
@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @coado in 9858e1e

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants