Skip to content

Commit 1752fdc

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Fix type for StyleSheet.compose()
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
1 parent 5663671 commit 1752fdc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Libraries/StyleSheet/StyleSheet.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ export namespace StyleSheet {
8787
* an array, saving allocations and maintaining reference equality for
8888
* PureComponent checks.
8989
*/
90-
export function compose<T>(
90+
export function compose<T, U>(
9191
style1: StyleProp<T> | Array<StyleProp<T>>,
92-
style2: StyleProp<T> | Array<StyleProp<T>>,
93-
): StyleProp<T>;
92+
style2: StyleProp<U> | Array<StyleProp<U>>,
93+
): StyleProp<T & U>;
9494

9595
/**
9696
* WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will

0 commit comments

Comments
 (0)