Enable flow in react-native-implementation

Summary:
I noticed I didn't get type defs anymore for react-native. Looks like it is broken since we removed the .flow file in 3e153b2a5b. To fix it we can now enable flow in react-native-implementation since it now supports properties.

**Test plan**
Tested that I get type hints when using imports from react-native in a project.
Closes https://github.com/facebook/react-native/pull/12917

Differential Revision: D4704753

Pulled By: ericvicenti

fbshipit-source-id: cf882588d7f371931de8d7861a1a6d50f6c425dc
This commit is contained in:
Janic Duplessis 2017-04-05 10:16:30 -07:00 коммит произвёл Facebook Github Bot
Родитель 9a51fa8e15
Коммит c7387fefc8
8 изменённых файлов: 53 добавлений и 60 удалений

Просмотреть файл

@ -198,7 +198,7 @@ class FlatListExample extends React.PureComponent {
this._listRef.getNode().recordInteraction();
pressItem(this, key);
};
_listRef: FlatList<*>;
_listRef: AnimatedFlatList;
}

Просмотреть файл

@ -49,7 +49,7 @@ class Tester extends React.Component {
this.current && this.props.reverseConfig ? this.props.reverseConfig : this.props.config
);
this.current = this.current ? 0 : 1;
const config = {
const config: Object = {
...animConfig,
toValue: this.current,
};

Просмотреть файл

@ -71,7 +71,7 @@ exports.examples = [
description: 'You can display <ScrollView>\'s child components horizontally rather than vertically',
render: function() {
function renderScrollView(title: string, addtionalStyles: StyleSheet) {
function renderScrollView(title: string, addtionalStyles: typeof StyleSheet) {
var _scrollView: ScrollView;
return (
<View style={addtionalStyles}>

Просмотреть файл

@ -33,6 +33,44 @@ var pickerStyleType = StyleSheetPropType({
var MODE_DIALOG = 'dialog';
var MODE_DROPDOWN = 'dropdown';
/**
* Individual selectable item in a Picker.
*/
class PickerItem extends React.Component {
props: {
label: string,
value?: any,
color?: ColorPropType,
testID?: string,
};
static propTypes = {
/**
* Text to display for this item.
*/
label: React.PropTypes.string.isRequired,
/**
* The value to be passed to picker's `onValueChange` callback when
* this item is selected. Can be a string or an integer.
*/
value: React.PropTypes.any,
/**
* Color of this item's text.
* @platform android
*/
color: ColorPropType,
/**
* Used to locate the item in end-to-end tests.
*/
testID: React.PropTypes.string,
};
render() {
// The items are not rendered directly
throw null;
}
}
/**
* Renders the native picker component on iOS and Android. Example:
*
@ -65,6 +103,8 @@ class Picker extends React.Component {
*/
static MODE_DROPDOWN = MODE_DROPDOWN;
static Item = PickerItem;
static defaultProps = {
mode: MODE_DIALOG,
};
@ -127,43 +167,4 @@ class Picker extends React.Component {
}
}
/**
* Individual selectable item in a Picker.
*/
// $FlowFixMe found when converting React.createClass to ES6
Picker.Item = class extends React.Component {
props: {
label: string,
value?: any,
color?: ColorPropType,
testID?: string,
};
static propTypes = {
/**
* Text to display for this item.
*/
label: React.PropTypes.string.isRequired,
/**
* The value to be passed to picker's `onValueChange` callback when
* this item is selected. Can be a string or an integer.
*/
value: React.PropTypes.any,
/**
* Color of this item's text.
* @platform android
*/
color: ColorPropType,
/**
* Used to locate the item in end-to-end tests.
*/
testID: React.PropTypes.string,
};
render() {
// The items are not rendered directly
throw null;
}
};
module.exports = Picker;

Просмотреть файл

@ -18,6 +18,11 @@ const SwipeableRow = require('SwipeableRow');
const {PropTypes} = React;
type DefaultProps = {
bounceFirstRowOnMount: boolean,
renderQuickActions: Function,
};
type Props = {
bounceFirstRowOnMount: boolean,
dataSource: SwipeableListViewDataSource,
@ -49,7 +54,7 @@ type State = {
* - It can bounce the 1st row of the list so users know it's swipeable
* - More to come
*/
class SwipeableListView extends React.Component {
class SwipeableListView extends React.Component<DefaultProps, Props, State> {
props: Props;
state: State;

Просмотреть файл

@ -194,7 +194,7 @@ var Image = React.createClass({
getSize(
url: string,
success: (width: number, height: number) => void,
failure: (error: any) => void,
failure?: (error: any) => void,
) {
return ImageLoader.getSize(url)
.then(function(sizes) {

Просмотреть файл

@ -304,7 +304,7 @@ const Image = React.createClass({
getSize: function(
uri: string,
success: (width: number, height: number) => void,
failure: (error: any) => void,
failure?: (error: any) => void,
) {
ImageViewManager.getSize(uri, success, failure || function() {
console.warn('Failed to get size for image: ' + uri);

Просмотреть файл

@ -7,24 +7,11 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule react-native-implementation
* @noflow - get/set properties not yet supported by flow. also `...require(x)` is broken #6560135
* @flow
*/
'use strict';
const invariant = require('fbjs/lib/invariant');
const warning = require('fbjs/lib/warning');
if (__DEV__) {
var warningDedupe = {};
var addonWarn = function(prevName, newPackageName) {
warning(
warningDedupe[prevName],
'React.addons.' + prevName + ' is deprecated. Please import the "' +
newPackageName + '" package instead.'
);
warningDedupe[prevName] = true;
};
}
// Export React, plus some native additions.
const ReactNative = {
@ -118,6 +105,7 @@ const ReactNative = {
get Platform() { return require('Platform'); },
get processColor() { return require('processColor'); },
get requireNativeComponent() { return require('requireNativeComponent'); },
get takeSnapshot() { return require('takeSnapshot'); },
// Prop Types
get ColorPropType() { return require('ColorPropType'); },
@ -133,7 +121,6 @@ const ReactNative = {
'and imported from `react-native-deprecated-custom-components` instead of `react-native`. ' +
'Learn about alternative navigation solutions at http://facebook.github.io/react-native/docs/navigation.html'
);
return null;
},
};