Skip to content

Commit

Permalink
Rename Style to DangerouslyImpreciseStyle
Browse files Browse the repository at this point in the history
Reviewed By: yungsters

Differential Revision: D7190268

fbshipit-source-id: d652a95be7550d65cfbfc59f41d7bda92915bacf
  • Loading branch information
elicwhite authored and facebook-github-bot committed Mar 8, 2018
1 parent 5b32358 commit 4895c64
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Libraries/StyleSheet/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ const flatten = require('flattenStyle');
import type {
____StyleSheetInternalStyleIdentifier_Internal as StyleSheetInternalStyleIdentifier,
____Styles_Internal,
____StyleObj_Internal,
____DangerouslyImpreciseStyleProp_Internal,
____ViewStyleProp_Internal,
____TextStyleProp_Internal,
____ImageStyleProp_Internal,
LayoutStyle,
} from 'StyleSheetTypes';

export type DangerouslyImpreciseStyleProp = ____StyleObj_Internal;
export type DangerouslyImpreciseStyleProp = ____DangerouslyImpreciseStyleProp_Internal;
export type ViewStyleProp = ____ViewStyleProp_Internal;
export type TextStyleProp = ____TextStyleProp_Internal;
export type ImageStyleProp = ____ImageStyleProp_Internal;
Expand Down
12 changes: 8 additions & 4 deletions Libraries/StyleSheet/StyleSheetTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export type ImageStyle = $ReadOnly<{|
overlayColor?: string,
|}>;

export type Style = {
export type DangerouslyImpreciseStyle = {
...$Exact<TextStyle>,
+resizeMode?: 'contain' | 'cover' | 'stretch' | 'center' | 'repeat',
+tintColor?: ColorValue,
Expand All @@ -230,7 +230,9 @@ type GenericStyleProp<+T> =
| ''
| $ReadOnlyArray<GenericStyleProp<T>>;

export type ____StyleObj_Internal = GenericStyleProp<$Shape<Style>>;
export type ____DangerouslyImpreciseStyleProp_Internal = GenericStyleProp<
$Shape<DangerouslyImpreciseStyle>,
>;
export type ____ViewStyleProp_Internal = GenericStyleProp<
$ReadOnly<$Shape<ViewStyle>>,
>;
Expand All @@ -242,7 +244,7 @@ export type ____ImageStyleProp_Internal = GenericStyleProp<
>;

export type ____Styles_Internal = {
+[key: string]: $Shape<Style>,
+[key: string]: $Shape<DangerouslyImpreciseStyle>,
};

/*
Expand All @@ -260,4 +262,6 @@ type Props = {position: TypeForStyleKey<'position'>};
This will correctly give you the type 'absolute' | 'relative' instead of the
weak type of just string;
*/
export type TypeForStyleKey<+key: $Keys<Style>> = $ElementType<Style, key>;
export type TypeForStyleKey<
+key: $Keys<DangerouslyImpreciseStyle>,
> = $ElementType<DangerouslyImpreciseStyle, key>;
7 changes: 5 additions & 2 deletions Libraries/StyleSheet/flattenStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*
* @providesModule flattenStyle
* @flow
* @format
*/
'use strict';

var ReactNativePropRegistry;

import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type { Style } from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyle} from 'StyleSheetTypes';

function getStyle(style) {
if (ReactNativePropRegistry === undefined) {
Expand All @@ -24,7 +25,9 @@ function getStyle(style) {
return style;
}

function flattenStyle(style: ?DangerouslyImpreciseStyleProp): ?Style {
function flattenStyle(
style: ?DangerouslyImpreciseStyleProp,
): ?DangerouslyImpreciseStyle {
if (style == null) {
return undefined;
}
Expand Down

0 comments on commit 4895c64

Please sign in to comment.