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
This commit is contained in:
Nick Gerleman
2022-12-14 14:59:05 -08:00
committed by Facebook GitHub Bot
parent 56636718f6
commit 1752fdc0f5
+3 -3
View File
@@ -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