Skip to content

Commit

Permalink
Make StyleSheet.create type private
Browse files Browse the repository at this point in the history
Summary:
This type is being used in many places where a much simpler type is often better. In a real pinch this type can still be accessed as so:

```
function returnsStyleSheet(
): $Call<typeof StyleSheet.create, *> {
  return StyleSheet.create({
    root: {
      background: 'white',
    }
  })
}

returnsStyleSheet().foo // foo doesn't exist
returnsStyleSheet().root // okay
```

Reviewed By: yungsters

Differential Revision: D7178524

fbshipit-source-id: 3c0ed03486ca00f1e287261e402fd47807f1fc3d
  • Loading branch information
elicwhite authored and facebook-github-bot committed Mar 7, 2018
1 parent cade297 commit ee26d9b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Libraries/StyleSheet/StyleSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ const flatten = require('flattenStyle');
import type {
StyleSheetStyle as _StyleSheetStyle,
Styles as _Styles,
StyleSheet as _StyleSheet,
StyleObj,
LayoutStyle
} from 'StyleSheetTypes';

export type StyleProp = StyleObj;
export type Styles = _Styles;
export type StyleSheet<S> = _StyleSheet<S>;
export type StyleSheetStyle = _StyleSheetStyle;
type StyleSheet<+S: Styles> = $ObjMap<S, (Object) => StyleSheetStyle>;

let hairlineWidth = PixelRatio.roundToNearestPixel(0.4);
if (hairlineWidth === 0) {
Expand Down
2 changes: 0 additions & 2 deletions Libraries/StyleSheet/StyleSheetTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ export type Styles = {
+[key: string]: $Shape<Style>,
};

export type StyleSheet<+S: Styles> = $ObjMap<S, (Object) => StyleSheetStyle>;

/*
Utility type get non-nullable types for specific style keys.
Useful when a component requires values for certain Style Keys.
Expand Down
12 changes: 3 additions & 9 deletions RNTester/js/RNTesterExampleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@ const RNTesterActions = require('./RNTesterActions');
const RNTesterStatePersister = require('./RNTesterStatePersister');
const View = require('View');

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

type Props = {
onNavigate: Function,
Expand Down

0 comments on commit ee26d9b

Please sign in to comment.