Skip to content

Commit

Permalink
Fix type for StyleSheet.compose()
Browse files Browse the repository at this point in the history
Summary:
This was flagged when typechecking the existing examples. The current type enforces that both stylesheets overlap, meaning composed stylesheets with distinct props cause a typechecking error. This changes the signature so that each style can be different, and the intersection type of the two is returned.

Changelog:
[General][Fixed] - Fix type for `StyleSheet.compose()`

Reviewed By: christophpurrer

Differential Revision: D42008355

fbshipit-source-id: 238971a61b387c09be001d5df50fe3db70df566f
  • Loading branch information
NickGerleman authored and Riccardo Cipolleschi committed Dec 19, 2022
1 parent 172f23a commit 754524e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Libraries/StyleSheet/StyleSheet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ export namespace StyleSheet {
* an array, saving allocations and maintaining reference equality for
* PureComponent checks.
*/
export function compose<T>(
export function compose<T, U>(
style1: StyleProp<T> | Array<StyleProp<T>>,
style2: StyleProp<T> | Array<StyleProp<T>>,
): StyleProp<T>;
style2: StyleProp<U> | Array<StyleProp<U>>,
): StyleProp<T & U>;

/**
* WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will
Expand Down

0 comments on commit 754524e

Please sign in to comment.