File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* @flow strict-local */
2
+ import type AnimatedValue from 'react-native/Libraries/Animated/nodes/AnimatedValue' ;
3
+ import type { DimensionValue } from 'react-native/Libraries/StyleSheet/StyleSheetTypes' ;
4
+ import type { ViewStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet' ;
5
+
6
+ import type { IsSupertype } from '../generics' ;
7
+ import type { ViewStylePropWithout } from '../reactNativeUtils' ;
8
+
9
+ function test_ViewStylePropWithout ( ) {
10
+ type ViewStyleNoHeight = ViewStylePropWithout < { |
11
+ height : DimensionValue ,
12
+ minHeight : DimensionValue ,
13
+ maxHeight : DimensionValue ,
14
+ | } > ;
15
+
16
+ // Is a subtype of ViewStyleProp
17
+ ( s : ViewStyleNoHeight ) : ViewStyleProp => s ;
18
+
19
+ // Accepts width-related attributes
20
+ ( s : { | minWidth : 10 , width : AnimatedValue , maxWidth : '100%' | } ) : ViewStyleNoHeight => s ;
21
+
22
+ // Doesn't accept height-related attributes
23
+ // $FlowExpectedError[incompatible-return]
24
+ ( s : { | minHeight : 10 | } ) : ViewStyleNoHeight => s ;
25
+ // $FlowExpectedError[incompatible-return]
26
+ ( s : { | height : AnimatedValue | } ) : ViewStyleNoHeight => s ;
27
+ // $FlowExpectedError[incompatible-return]
28
+ ( s : { | maxHeight : '100%' | } ) : ViewStyleNoHeight => s ;
29
+ }
Original file line number Diff line number Diff line change
1
+ /* @flow strict-local */
2
+
3
+ // eslint-disable-next-line id-match
4
+ import type { ____ViewStyle_Internal } from 'react-native/Libraries/StyleSheet/StyleSheetTypes' ;
5
+
6
+ import type { BoundedDiff } from './generics' ;
7
+
8
+ // A copy of the same-named type in
9
+ // node_modules/react-native/Libraries/StyleSheet/StyleSheetTypes.js, for
10
+ // use in ViewStylePropWithout, below.
11
+ type GenericStyleProp < + T > = null | void | T | false | '' | $ReadOnlyArray < GenericStyleProp < T >> ;
12
+
13
+ /**
14
+ * `View`'s style prop, but without the style attributes defined in T.
15
+ */
16
+ // RN's type for `View`'s style prop is `ViewStyleProp` in
17
+ // node_modules/react-native/Libraries/StyleSheet/StyleSheet.js; our
18
+ // implementation builds on a copy of that.
19
+ export type ViewStylePropWithout < T : { ... } > = GenericStyleProp <
20
+ // Uses unsound $Shape just because the upstream type does, and we're
21
+ // copying that.
22
+ $ReadOnly < $Shape < BoundedDiff < ____ViewStyle_Internal , T >>> ,
23
+ > ;
You can’t perform that action at this time.
0 commit comments