flowify some Libraries

This commit is contained in:
Basil Hosmer 2015-03-25 11:12:57 -07:00
parent d0d6dbffb3
commit 18b6d5c20d
7 changed files with 23 additions and 7 deletions

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule NativeModules
* @flow
*/
'use strict';

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RCTAlertManager
* @flow
*/
'use strict';

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RCTEventEmitter
* @flow
*/
'use strict';

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RCTJSTimers
* @flow
*/
'use strict';

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule CameraRoll
* @flow
*/
'use strict';
@ -28,7 +29,8 @@ var GROUP_TYPES_OPTIONS = [
'SavedPhotos', // default
];
deepFreezeAndThrowOnMutationInDev(GROUP_TYPES_OPTIONS);
// Flow treats Object and Array as disjoint types, currently.
deepFreezeAndThrowOnMutationInDev((GROUP_TYPES_OPTIONS: any));
/**
* Shape of the param arg for the `getPhotos` function.

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RCTDeviceEventEmitter
* @flow
*/
'use strict';

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Geolocation
* @flow
*/
'use strict';
@ -33,7 +34,10 @@ var updatesEnabled = false;
*/
var Geolocation = {
getCurrentPosition: function(geo_success, geo_error, geo_options) {
getCurrentPosition: function(
geo_success: Function,
geo_error?: Function,
geo_options?: Object) {
invariant(
typeof geo_success === 'function',
'Must provide a valid geo_success callback.'
@ -45,7 +49,7 @@ var Geolocation = {
);
},
watchPosition: function(success, error, options) {
watchPosition: function(success: Function, error?: Function, options?: Object): number {
if (!updatesEnabled) {
RCTLocationObserver.startObserving(options || {});
updatesEnabled = true;
@ -64,15 +68,17 @@ var Geolocation = {
return watchID;
},
clearWatch: function(watchID) {
clearWatch: function(watchID: number) {
var sub = subscriptions[watchID];
if (!sub) {
// Silently exit when the watchID is invalid or already cleared
// This is consistent with timers
return;
}
sub[0].remove();
sub[1] && sub[1].remove();
// array element refinements not yet enabled in Flow
var sub1 = sub[1]; sub1 && sub1.remove();
subscriptions[watchID] = undefined;
var noWatchers = true;
for (var ii = 0; ii < subscriptions.length; ii++) {
@ -90,9 +96,12 @@ var Geolocation = {
RCTLocationObserver.stopObserving();
updatesEnabled = false;
for (var ii = 0; ii < subscriptions.length; ii++) {
if (subscriptions[ii]) {
var sub = subscriptions[ii];
if (sub) {
warning('Called stopObserving with existing subscriptions.');
subscriptions[ii].remove();
sub[0].remove();
// array element refinements not yet enabled in Flow
var sub1 = sub[1]; sub1 && sub1.remove();
}
}
subscriptions = [];