diff --git a/Examples/UIExplorer/ActionSheetIOSExample.js b/Examples/UIExplorer/ActionSheetIOSExample.js
index 9b164de14..1ee487ed5 100644
--- a/Examples/UIExplorer/ActionSheetIOSExample.js
+++ b/Examples/UIExplorer/ActionSheetIOSExample.js
@@ -1,6 +1,7 @@
/**
-* * Copyright 2004-present Facebook. All Rights Reserved.
-* */
+ * Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
+ */
'use strict';
var React = require('react-native');
@@ -103,10 +104,10 @@ exports.description = 'Interface to show iOS\' action sheets';
exports.examples = [
{
title: 'Show Action Sheet',
- render() { return ; }
+ render(): ReactElement { return ; }
},
{
title: 'Show Share Action Sheet',
- render() { return ; }
+ render(): ReactElement { return ; }
}
];
diff --git a/Examples/UIExplorer/ActivityIndicatorExample.js b/Examples/UIExplorer/ActivityIndicatorExample.js
index 3371551a0..60f69843c 100644
--- a/Examples/UIExplorer/ActivityIndicatorExample.js
+++ b/Examples/UIExplorer/ActivityIndicatorExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
@@ -128,7 +129,7 @@ exports.examples = [
},
{
title: 'Start/stop',
- render: function() {
+ render: function(): ReactElement {
return ;
}
},
diff --git a/Examples/UIExplorer/AdSupportIOSExample.js b/Examples/UIExplorer/AdSupportIOSExample.js
index a3d720f01..4047dd43a 100644
--- a/Examples/UIExplorer/AdSupportIOSExample.js
+++ b/Examples/UIExplorer/AdSupportIOSExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
@@ -19,7 +20,7 @@ exports.description = 'Example of using the ad support API.';
exports.examples = [
{
title: 'Ad Support IOS',
- render: function() {
+ render: function(): ReactElement {
return ;
},
}
diff --git a/Examples/UIExplorer/AlertIOSExample.js b/Examples/UIExplorer/AlertIOSExample.js
index a2b92d975..6897007fc 100644
--- a/Examples/UIExplorer/AlertIOSExample.js
+++ b/Examples/UIExplorer/AlertIOSExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
diff --git a/Examples/UIExplorer/AppStateExample.js b/Examples/UIExplorer/AppStateExample.js
index ea6400b91..9e93a57fc 100644
--- a/Examples/UIExplorer/AppStateExample.js
+++ b/Examples/UIExplorer/AppStateExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
diff --git a/Examples/UIExplorer/AppStateIOSExample.js b/Examples/UIExplorer/AppStateIOSExample.js
index 845b2e049..e28857fc8 100644
--- a/Examples/UIExplorer/AppStateIOSExample.js
+++ b/Examples/UIExplorer/AppStateIOSExample.js
@@ -2,6 +2,7 @@
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule AppStateIOSExample
+ * @flow
*/
'use strict';
@@ -60,10 +61,10 @@ exports.examples = [
{
title: 'Subscribed AppStateIOS:',
description: 'This changes according to the current state, so you can only ever see it rendered as "active"',
- render() { return ; }
+ render(): ReactElement { return ; }
},
{
title: 'Previous states:',
- render() { return ; }
+ render(): ReactElement { return ; }
},
];
diff --git a/Examples/UIExplorer/AsyncStorageExample.js b/Examples/UIExplorer/AsyncStorageExample.js
index 3a2579fa7..6064147fd 100644
--- a/Examples/UIExplorer/AsyncStorageExample.js
+++ b/Examples/UIExplorer/AsyncStorageExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
@@ -98,6 +99,6 @@ exports.description = 'Asynchronous local disk storage.';
exports.examples = [
{
title: 'Basics - getItem, setItem, removeItem',
- render() { return ; }
+ render(): ReactElement { return ; }
},
];
diff --git a/Examples/UIExplorer/CameraRollExample.ios.js b/Examples/UIExplorer/CameraRollExample.ios.js
index 7be014a33..dbc817bf5 100644
--- a/Examples/UIExplorer/CameraRollExample.ios.js
+++ b/Examples/UIExplorer/CameraRollExample.ios.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
@@ -108,6 +109,6 @@ exports.description = 'Example component that uses CameraRoll to list user\'s ph
exports.examples = [
{
title: 'Photos',
- render() { return ; }
+ render(): ReactElement { return ; }
}
];
diff --git a/Examples/UIExplorer/CameraRollView.ios.js b/Examples/UIExplorer/CameraRollView.ios.js
index c8a9a2829..2e1364eed 100644
--- a/Examples/UIExplorer/CameraRollView.ios.js
+++ b/Examples/UIExplorer/CameraRollView.ios.js
@@ -2,6 +2,7 @@
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule CameraRollView
+ * @flow
*/
'use strict';
@@ -53,7 +54,7 @@ var propTypes = {
var CameraRollView = React.createClass({
propTypes: propTypes,
- getDefaultProps: function() {
+ getDefaultProps: function(): Object {
return {
groupTypes: 'SavedPhotos',
batchSize: 5,
@@ -75,9 +76,9 @@ var CameraRollView = React.createClass({
var ds = new ListView.DataSource({rowHasChanged: this._rowHasChanged});
return {
- assets: [],
+ assets: ([]: Array),
groupTypes: this.props.groupTypes,
- lastCursor: null,
+ lastCursor: (null : ?string),
noMore: false,
loadingMore: false,
dataSource: ds,
@@ -99,21 +100,21 @@ var CameraRollView = React.createClass({
this.fetch();
},
- componentWillReceiveProps: function(nextProps) {
+ componentWillReceiveProps: function(nextProps: {groupTypes?: string}) {
if (this.props.groupTypes !== nextProps.groupTypes) {
this.fetch(true);
}
},
- _fetch: function(clear) {
+ _fetch: function(clear?: boolean) {
if (clear) {
this.setState(this.getInitialState(), this.fetch);
return;
}
- var fetchParams = {
+ var fetchParams: Object = {
first: this.props.batchSize,
- groupTypes: this.props.groupTypes,
+ groupTypes: this.props.groupTypes
};
if (this.state.lastCursor) {
fetchParams.after = this.state.lastCursor;
@@ -126,7 +127,7 @@ var CameraRollView = React.createClass({
* Fetches more images from the camera roll. If clear is set to true, it will
* set the component to its initial state and re-fetch the images.
*/
- fetch: function(clear) {
+ fetch: function(clear?: boolean) {
if (!this.state.loadingMore) {
this.setState({loadingMore: true}, () => { this._fetch(clear); });
}
@@ -144,7 +145,7 @@ var CameraRollView = React.createClass({
);
},
- _rowHasChanged: function(r1, r2) {
+ _rowHasChanged: function(r1: Array, r2: Array): boolean {
if (r1.length !== r2.length) {
return true;
}
@@ -166,7 +167,7 @@ var CameraRollView = React.createClass({
},
// rowData is an array of images
- _renderRow: function(rowData, sectionID, rowID) {
+ _renderRow: function(rowData: Array, sectionID: string, rowID: string) {
var images = rowData.map((image) => {
if (image === null) {
return null;
@@ -181,9 +182,9 @@ var CameraRollView = React.createClass({
);
},
- _appendAssets: function(data) {
+ _appendAssets: function(data: Object) {
var assets = data.edges;
- var newState = { loadingMore: false };
+ var newState: Object = { loadingMore: false };
if (!data.page_info.has_next_page) {
newState.noMore = true;
diff --git a/Examples/UIExplorer/DatePickerExample.js b/Examples/UIExplorer/DatePickerExample.js
index ab8b17625..4382f929f 100644
--- a/Examples/UIExplorer/DatePickerExample.js
+++ b/Examples/UIExplorer/DatePickerExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
@@ -118,7 +119,7 @@ exports.description = 'Select dates and times using the native UIDatePicker.';
exports.examples = [
{
title: '',
- render: function() {
+ render: function(): ReactElement {
return ;
},
}];
diff --git a/Examples/UIExplorer/GeolocationExample.js b/Examples/UIExplorer/GeolocationExample.js
index 78ba29b9d..38d720ba7 100644
--- a/Examples/UIExplorer/GeolocationExample.js
+++ b/Examples/UIExplorer/GeolocationExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
/* eslint no-console: 0 */
'use strict';
@@ -19,13 +20,15 @@ exports.description = 'Examples of using the Geolocation API.';
exports.examples = [
{
title: 'navigator.geolocation',
- render: function() {
+ render: function(): ReactElement {
return ;
},
}
];
var GeolocationExample = React.createClass({
+ watchID: (null: ?number),
+
getInitialState: function() {
return {
initialPosition: 'unknown',
diff --git a/Examples/UIExplorer/LayoutExample.js b/Examples/UIExplorer/LayoutExample.js
index 2586694ec..ab8b3dc65 100644
--- a/Examples/UIExplorer/LayoutExample.js
+++ b/Examples/UIExplorer/LayoutExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+ * @flow
*/
'use strict';
diff --git a/Examples/UIExplorer/ListViewSimpleExample.js b/Examples/UIExplorer/ListViewSimpleExample.js
index c0a84fc54..b3f0f8c96 100644
--- a/Examples/UIExplorer/ListViewSimpleExample.js
+++ b/Examples/UIExplorer/ListViewSimpleExample.js
@@ -1,5 +1,6 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
+* @flow
*/
'use strict';
@@ -28,6 +29,8 @@ var ListViewSimpleExample = React.createClass({
};
},
+ _pressData: ({}: {[key: number]: boolean}),
+
componentWillMount: function() {
this._pressData = {};
},
@@ -46,7 +49,7 @@ var ListViewSimpleExample = React.createClass({
);
},
- _renderRow: function(rowData, sectionID, rowID) {
+ _renderRow: function(rowData: string, sectionID: number, rowID: number) {
var rowHash = Math.abs(hashCode(rowData));
var imgSource = {
uri: THUMB_URLS[rowHash % THUMB_URLS.length],
@@ -66,7 +69,7 @@ var ListViewSimpleExample = React.createClass({
);
},
- _genRows: function(pressData) {
+ _genRows: function(pressData: {[key: number]: boolean}): Array {
var dataBlob = [];
for (var ii = 0; ii < 100; ii++) {
var pressedText = pressData[ii] ? ' (pressed)' : '';
@@ -75,7 +78,7 @@ var ListViewSimpleExample = React.createClass({
return dataBlob;
},
- _pressRow: function(rowID) {
+ _pressRow: function(rowID: number) {
this._pressData[rowID] = !this._pressData[rowID];
this.setState({dataSource: this.state.dataSource.cloneWithRows(
this._genRows(this._pressData)
diff --git a/Libraries/Utilities/AlertIOS.js b/Libraries/Utilities/AlertIOS.js
index 8a342004c..3b2530f18 100644
--- a/Libraries/Utilities/AlertIOS.js
+++ b/Libraries/Utilities/AlertIOS.js
@@ -44,7 +44,7 @@ class AlertIOS {
static alert(
title: ?string,
message: ?string,
- buttons: ?Array<{
+ buttons?: Array<{
text: ?string;
onPress: ?Function;
}>