Rename Style to DangerouslyImpreciseStyle

Reviewed By: yungsters

Differential Revision: D7190268

fbshipit-source-id: d652a95be7550d65cfbfc59f41d7bda92915bacf
This commit is contained in:
Eli White 2018-03-08 00:35:58 -08:00 committed by Facebook Github Bot
parent 5b32358c9e
commit 4895c645ea
3 changed files with 15 additions and 8 deletions

View File

@ -20,14 +20,14 @@ const flatten = require('flattenStyle');
import type { import type {
____StyleSheetInternalStyleIdentifier_Internal as StyleSheetInternalStyleIdentifier, ____StyleSheetInternalStyleIdentifier_Internal as StyleSheetInternalStyleIdentifier,
____Styles_Internal, ____Styles_Internal,
____StyleObj_Internal, ____DangerouslyImpreciseStyleProp_Internal,
____ViewStyleProp_Internal, ____ViewStyleProp_Internal,
____TextStyleProp_Internal, ____TextStyleProp_Internal,
____ImageStyleProp_Internal, ____ImageStyleProp_Internal,
LayoutStyle, LayoutStyle,
} from 'StyleSheetTypes'; } from 'StyleSheetTypes';
export type DangerouslyImpreciseStyleProp = ____StyleObj_Internal; export type DangerouslyImpreciseStyleProp = ____DangerouslyImpreciseStyleProp_Internal;
export type ViewStyleProp = ____ViewStyleProp_Internal; export type ViewStyleProp = ____ViewStyleProp_Internal;
export type TextStyleProp = ____TextStyleProp_Internal; export type TextStyleProp = ____TextStyleProp_Internal;
export type ImageStyleProp = ____ImageStyleProp_Internal; export type ImageStyleProp = ____ImageStyleProp_Internal;

View File

@ -213,7 +213,7 @@ export type ImageStyle = $ReadOnly<{|
overlayColor?: string, overlayColor?: string,
|}>; |}>;
export type Style = { export type DangerouslyImpreciseStyle = {
...$Exact<TextStyle>, ...$Exact<TextStyle>,
+resizeMode?: 'contain' | 'cover' | 'stretch' | 'center' | 'repeat', +resizeMode?: 'contain' | 'cover' | 'stretch' | 'center' | 'repeat',
+tintColor?: ColorValue, +tintColor?: ColorValue,
@ -230,7 +230,9 @@ type GenericStyleProp<+T> =
| '' | ''
| $ReadOnlyArray<GenericStyleProp<T>>; | $ReadOnlyArray<GenericStyleProp<T>>;
export type ____StyleObj_Internal = GenericStyleProp<$Shape<Style>>; export type ____DangerouslyImpreciseStyleProp_Internal = GenericStyleProp<
$Shape<DangerouslyImpreciseStyle>,
>;
export type ____ViewStyleProp_Internal = GenericStyleProp< export type ____ViewStyleProp_Internal = GenericStyleProp<
$ReadOnly<$Shape<ViewStyle>>, $ReadOnly<$Shape<ViewStyle>>,
>; >;
@ -242,7 +244,7 @@ export type ____ImageStyleProp_Internal = GenericStyleProp<
>; >;
export type ____Styles_Internal = { export type ____Styles_Internal = {
+[key: string]: $Shape<Style>, +[key: string]: $Shape<DangerouslyImpreciseStyle>,
}; };
/* /*
@ -260,4 +262,6 @@ type Props = {position: TypeForStyleKey<'position'>};
This will correctly give you the type 'absolute' | 'relative' instead of the This will correctly give you the type 'absolute' | 'relative' instead of the
weak type of just string; weak type of just string;
*/ */
export type TypeForStyleKey<+key: $Keys<Style>> = $ElementType<Style, key>; export type TypeForStyleKey<
+key: $Keys<DangerouslyImpreciseStyle>,
> = $ElementType<DangerouslyImpreciseStyle, key>;

View File

@ -6,13 +6,14 @@
* *
* @providesModule flattenStyle * @providesModule flattenStyle
* @flow * @flow
* @format
*/ */
'use strict'; 'use strict';
var ReactNativePropRegistry; var ReactNativePropRegistry;
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet'; import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type { Style } from 'StyleSheetTypes'; import type {DangerouslyImpreciseStyle} from 'StyleSheetTypes';
function getStyle(style) { function getStyle(style) {
if (ReactNativePropRegistry === undefined) { if (ReactNativePropRegistry === undefined) {
@ -24,7 +25,9 @@ function getStyle(style) {
return style; return style;
} }
function flattenStyle(style: ?DangerouslyImpreciseStyleProp): ?Style { function flattenStyle(
style: ?DangerouslyImpreciseStyleProp,
): ?DangerouslyImpreciseStyle {
if (style == null) { if (style == null) {
return undefined; return undefined;
} }