diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index b84fedf0c..20150d6f6 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ActionSheetIOS + * @flow */ 'use strict'; @@ -15,7 +16,7 @@ var RCTActionSheetManager = require('NativeModules').ActionSheetManager; var invariant = require('invariant'); var ActionSheetIOS = { - showActionSheetWithOptions(options, callback) { + showActionSheetWithOptions(options: Object, callback: Function) { invariant( typeof options === 'object' && options !== null, 'Options must a valid object' @@ -31,7 +32,11 @@ var ActionSheetIOS = { ); }, - showShareActionSheetWithOptions(options, failureCallback, successCallback) { + showShareActionSheetWithOptions( + options: Object, + failureCallback: Function, + successCallback: Function + ) { invariant( typeof options === 'object' && options !== null, 'Options must a valid object' diff --git a/Libraries/AdSupport/AdSupportIOS.js b/Libraries/AdSupport/AdSupportIOS.js index 0f2a4c2a6..d9d315a1d 100644 --- a/Libraries/AdSupport/AdSupportIOS.js +++ b/Libraries/AdSupport/AdSupportIOS.js @@ -7,17 +7,18 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule AdSupportIOS + * @flow */ 'use strict'; var AdSupport = require('NativeModules').AdSupport; module.exports = { - getAdvertisingId: function(onSuccess, onFailure) { + getAdvertisingId: function(onSuccess: Function, onFailure: Function) { AdSupport.getAdvertisingId(onSuccess, onFailure); }, - getAdvertisingTrackingEnabled: function(onSuccess, onFailure) { + getAdvertisingTrackingEnabled: function(onSuccess: Function, onFailure: Function) { AdSupport.getAdvertisingTrackingEnabled(onSuccess, onFailure); }, }; diff --git a/Libraries/Animation/LayoutAnimation.js b/Libraries/Animation/LayoutAnimation.js index 8752e2322..b68656984 100644 --- a/Libraries/Animation/LayoutAnimation.js +++ b/Libraries/Animation/LayoutAnimation.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule LayoutAnimation + * @flow */ 'use strict'; @@ -42,6 +43,15 @@ var animChecker = createStrictShapeTypeChecker({ ), }); +type Anim = { + duration?: number; + delay?: number; + springDamping?: number; + initialVelocity?: number; + type?: $Enum; + property?: $Enum; +} + var configChecker = createStrictShapeTypeChecker({ duration: PropTypes.number.isRequired, create: animChecker, @@ -49,46 +59,56 @@ var configChecker = createStrictShapeTypeChecker({ delete: animChecker, }); -var LayoutAnimation = { - configureNext(config, onAnimationDidEnd, onError) { - configChecker({config}, 'config', 'LayoutAnimation.configureNext'); - RCTUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError); - }, - create(duration, type, creationProp) { - return { - duration, - create: { - type, - property: creationProp, - }, - update: { - type, - }, - }; - }, - Types: Types, - Properties: Properties, - configChecker: configChecker, -}; +type Config = { + duration: number; + create?: Anim; + update?: Anim; + delete?: Anim; +} -LayoutAnimation.Presets = { - easeInEaseOut: LayoutAnimation.create( - 0.3, Types.easeInEaseOut, Properties.opacity - ), - linear: LayoutAnimation.create( - 0.5, Types.linear, Properties.opacity - ), - spring: { - duration: 0.7, +function configureNext(config: Config, onAnimationDidEnd?: Function, onError?: Function) { + configChecker({config}, 'config', 'LayoutAnimation.configureNext'); + RCTUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError); +} + +function create(duration: number, type, creationProp): Config { + return { + duration, create: { - type: Types.linear, - property: Properties.opacity, + type, + property: creationProp, }, update: { - type: Types.spring, - springDamping: 0.4, + type, }, - }, + }; +} + +var LayoutAnimation = { + configureNext, + create, + Types, + Properties, + configChecker: configChecker, + Presets: { + easeInEaseOut: create( + 0.3, Types.easeInEaseOut, Properties.opacity + ), + linear: create( + 0.5, Types.linear, Properties.opacity + ), + spring: { + duration: 0.7, + create: { + type: Types.linear, + property: Properties.opacity, + }, + update: { + type: Types.spring, + springDamping: 0.4, + }, + }, + } }; module.exports = LayoutAnimation; diff --git a/Libraries/AppRegistry/AppRegistry.js b/Libraries/AppRegistry/AppRegistry.js index 40498adac..f36f88132 100644 --- a/Libraries/AppRegistry/AppRegistry.js +++ b/Libraries/AppRegistry/AppRegistry.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule AppRegistry + * @flow */ 'use strict'; @@ -21,6 +22,12 @@ if (__DEV__) { var runnables = {}; +type AppConfig = { + appKey: string; + component: ReactClass; + run?: Function; +}; + /** * `AppRegistry` is the JS entry point to running all React Native apps. App * root components should register themselves with @@ -33,17 +40,18 @@ var runnables = {}; * `require`d. */ var AppRegistry = { - registerConfig: function(config) { + registerConfig: function(config: Array) { for (var i = 0; i < config.length; ++i) { - if (config[i].run) { - AppRegistry.registerRunnable(config[i].appKey, config[i].run); + var appConfig = config[i]; + if (appConfig.run) { + AppRegistry.registerRunnable(appConfig.appKey, appConfig.run); } else { - AppRegistry.registerComponent(config[i].appKey, config[i].component); + AppRegistry.registerComponent(appConfig.appKey, appConfig.component); } } }, - registerComponent: function(appKey, getComponentFunc) { + registerComponent: function(appKey: string, getComponentFunc: Function): string { runnables[appKey] = { run: (appParameters) => renderApplication(getComponentFunc(), appParameters.initialProps, appParameters.rootTag) @@ -51,12 +59,12 @@ var AppRegistry = { return appKey; }, - registerRunnable: function(appKey, func) { + registerRunnable: function(appKey: string, func: Function): string { runnables[appKey] = {run: func}; return appKey; }, - runApplication: function(appKey, appParameters) { + runApplication: function(appKey: string, appParameters: any): void { console.log( 'Running application "' + appKey + '" with appParams: ' + JSON.stringify(appParameters) + '. ' + diff --git a/Libraries/AppStateIOS/AppStateIOS.android.js b/Libraries/AppStateIOS/AppStateIOS.android.js index 9fbad761e..b8c3e8def 100644 --- a/Libraries/AppStateIOS/AppStateIOS.android.js +++ b/Libraries/AppStateIOS/AppStateIOS.android.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule AppStateIOS + * @flow */ 'use strict'; diff --git a/Libraries/AppStateIOS/AppStateIOS.ios.js b/Libraries/AppStateIOS/AppStateIOS.ios.js index ecb2ee49e..af6893534 100644 --- a/Libraries/AppStateIOS/AppStateIOS.ios.js +++ b/Libraries/AppStateIOS/AppStateIOS.ios.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule AppStateIOS + * @flow */ 'use strict';