Skip to content

Commit

Permalink
StyleObj -> DangerouslyImpreciseStyleProp
Browse files Browse the repository at this point in the history
Summary:
Migrating everything to import from StyleSheet instead of StyleSheetTypes.

Search and replaced
```
import type {StyleObj} from 'StyleSheetTypes';
```
to
```
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
```

and then replacing `StyleObj` with `DangerouslyImpreciseStyleProp` and fixing up the remaining flow errors by hand.

Reviewed By: yungsters

Differential Revision: D7184077

fbshipit-source-id: b8dabb9d48038b5a997ab715687300bad57aa9d4
  • Loading branch information
elicwhite authored and facebook-github-bot committed Mar 7, 2018
1 parent 49ffc9f commit a3c07c9
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Libraries/Components/TabBarIOS/TabBarIOS.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const ViewPropTypes = require('ViewPropTypes');

const requireNativeComponent = require('requireNativeComponent');

import type {StyleObj} from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type {ViewProps} from 'ViewPropTypes';

class TabBarIOS extends React.Component<ViewProps & {
style?: StyleObj,
style?: DangerouslyImpreciseStyleProp,
unselectedTintColor?: string,
tintColor?: string,
unselectedItemTintColor?: string,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Inspector/ElementProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const flattenStyle = require('flattenStyle');
const mapWithSeparator = require('mapWithSeparator');
const openFileInEditor = require('openFileInEditor');

import type {StyleObj} from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';

class ElementProperties extends React.Component<{
hierarchy: Array<$FlowFixMe>,
style?: StyleObj,
style?: DangerouslyImpreciseStyleProp,
source?: {
fileName?: string,
lineNumber?: number,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ListView = require('ListView');

const invariant = require('fbjs/lib/invariant');

import type {StyleObj} from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type {
ViewabilityConfig,
ViewToken,
Expand Down Expand Up @@ -96,7 +96,7 @@ type OptionalProps<ItemT> = {
/**
* Optional custom style for multi-item rows generated when numColumns > 1.
*/
columnWrapperStyle?: StyleObj,
columnWrapperStyle?: DangerouslyImpreciseStyleProp,
/**
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const warning = require('fbjs/lib/warning');

const {computeWindowedRenderLimits} = require('VirtualizeUtils');

import type {StyleObj} from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type {
ViewabilityConfig,
ViewToken,
Expand Down Expand Up @@ -644,7 +644,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
stickyIndicesFromProps: Set<number>,
first: number,
last: number,
inversionStyle: ?StyleObj,
inversionStyle: ?DangerouslyImpreciseStyleProp,
) {
const {
CellRendererComponent,
Expand Down Expand Up @@ -1545,7 +1545,7 @@ class CellRenderer extends React.Component<
fillRateHelper: FillRateHelper,
horizontal: ?boolean,
index: number,
inversionStyle: ?StyleObj,
inversionStyle: ?DangerouslyImpreciseStyleProp,
item: Item,
onLayout: (event: Object) => void, // This is extracted by ScrollViewStickyHeader
onUnmount: (cellKey: string) => void,
Expand Down
4 changes: 2 additions & 2 deletions Libraries/StyleSheet/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ const flatten = require('flattenStyle');
import type {
StyleSheetStyle as _StyleSheetStyle,
Styles as _Styles,
StyleObj,
____StyleObj_Internal,
LayoutStyle
} from 'StyleSheetTypes';

export type DangerouslyImpreciseStyleProp = StyleObj;
export type DangerouslyImpreciseStyleProp = ____StyleObj_Internal;
export type Styles = _Styles;
export type StyleSheetStyle = _StyleSheetStyle;
type StyleSheet<+S: Styles> = $ObjMap<S, (Object) => StyleSheetStyle>;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/StyleSheet/StyleSheetTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ type GenericStyleProp<+T> =
| ''
| $ReadOnlyArray<GenericStyleProp<T>>;

export type StyleObj = GenericStyleProp<$Shape<Style>>;
export type ____StyleObj_Internal = GenericStyleProp<$Shape<Style>>;

export type ViewStyleProp = GenericStyleProp<$ReadOnly<$Shape<ViewStyle>>>;
export type TextStyleProp = GenericStyleProp<$ReadOnly<$Shape<TextStyle>>>;
Expand Down
5 changes: 3 additions & 2 deletions Libraries/StyleSheet/flattenStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

var ReactNativePropRegistry;

import type { StyleObj, Style } from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';
import type { Style } from 'StyleSheetTypes';

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

function flattenStyle(style: ?StyleObj): ?Style {
function flattenStyle(style: ?DangerouslyImpreciseStyleProp): ?Style {
if (style == null) {
return undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions RNTester/js/RNTesterExampleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const View = require('View');

import type {RNTesterExample} from './RNTesterList.ios';
import type {PassProps} from './RNTesterStatePersister';
import type {StyleObj} from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';

type Props = {
onNavigate: Function,
Expand All @@ -31,8 +31,8 @@ type Props = {
APIExamples: Array<RNTesterExample>,
},
persister: PassProps<*>,
searchTextInputStyle: StyleObj,
style?: ?StyleObj,
searchTextInputStyle: DangerouslyImpreciseStyleProp,
style?: ?DangerouslyImpreciseStyleProp,
};

class RowComponent extends React.PureComponent<{
Expand Down
4 changes: 2 additions & 2 deletions RNTester/js/ScrollViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
'use strict';

import type {StyleObj} from 'StyleSheetTypes';
import type {DangerouslyImpreciseStyleProp} from 'StyleSheet';

const ActivityIndicator = require('ActivityIndicator');
const Platform = require('Platform');
Expand Down Expand Up @@ -252,7 +252,7 @@ if (Platform.OS === 'ios') {
class Thumb extends React.PureComponent<{|
source?: string | number,
msg?: string,
style?: StyleObj,
style?: DangerouslyImpreciseStyleProp,
|}> {
render() {
const {source} = this.props;
Expand Down

0 comments on commit a3c07c9

Please sign in to comment.