Skip to content

Commit e4bf45b

Browse files
author
Basil Hosmer
committed
flowify some Libraries
1 parent 6daf7d2 commit e4bf45b

6 files changed

Lines changed: 81 additions & 45 deletions

File tree

Libraries/ActionSheetIOS/ActionSheetIOS.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule ActionSheetIOS
10+
* @flow
1011
*/
1112
'use strict';
1213

@@ -15,7 +16,7 @@ var RCTActionSheetManager = require('NativeModules').ActionSheetManager;
1516
var invariant = require('invariant');
1617

1718
var ActionSheetIOS = {
18-
showActionSheetWithOptions(options, callback) {
19+
showActionSheetWithOptions(options: Object, callback: Function) {
1920
invariant(
2021
typeof options === 'object' && options !== null,
2122
'Options must a valid object'
@@ -31,7 +32,11 @@ var ActionSheetIOS = {
3132
);
3233
},
3334

34-
showShareActionSheetWithOptions(options, failureCallback, successCallback) {
35+
showShareActionSheetWithOptions(
36+
options: Object,
37+
failureCallback: Function,
38+
successCallback: Function
39+
) {
3540
invariant(
3641
typeof options === 'object' && options !== null,
3742
'Options must a valid object'

Libraries/AdSupport/AdSupportIOS.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule AdSupportIOS
10+
* @flow
1011
*/
1112
'use strict';
1213

1314
var AdSupport = require('NativeModules').AdSupport;
1415

1516
module.exports = {
16-
getAdvertisingId: function(onSuccess, onFailure) {
17+
getAdvertisingId: function(onSuccess: Function, onFailure: Function) {
1718
AdSupport.getAdvertisingId(onSuccess, onFailure);
1819
},
1920

20-
getAdvertisingTrackingEnabled: function(onSuccess, onFailure) {
21+
getAdvertisingTrackingEnabled: function(onSuccess: Function, onFailure: Function) {
2122
AdSupport.getAdvertisingTrackingEnabled(onSuccess, onFailure);
2223
},
2324
};

Libraries/Animation/LayoutAnimation.js

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule LayoutAnimation
10+
* @flow
1011
*/
1112
'use strict';
1213

@@ -42,53 +43,72 @@ var animChecker = createStrictShapeTypeChecker({
4243
),
4344
});
4445

46+
type Anim = {
47+
duration?: number;
48+
delay?: number;
49+
springDamping?: number;
50+
initialVelocity?: number;
51+
type?: $Enum<typeof Types>;
52+
property?: $Enum<typeof Properties>;
53+
}
54+
4555
var configChecker = createStrictShapeTypeChecker({
4656
duration: PropTypes.number.isRequired,
4757
create: animChecker,
4858
update: animChecker,
4959
delete: animChecker,
5060
});
5161

62+
type Config = {
63+
duration: number;
64+
create?: Anim;
65+
update?: Anim;
66+
delete?: Anim;
67+
}
68+
69+
function configureNext(config: Config, onAnimationDidEnd?: Function, onError?: Function) {
70+
configChecker({config}, 'config', 'LayoutAnimation.configureNext');
71+
RCTUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError);
72+
}
73+
74+
function create(duration: number, type, creationProp): Config {
75+
return {
76+
duration,
77+
create: {
78+
type,
79+
property: creationProp,
80+
},
81+
update: {
82+
type,
83+
},
84+
};
85+
}
86+
5287
var LayoutAnimation = {
53-
configureNext(config, onAnimationDidEnd, onError) {
54-
configChecker({config}, 'config', 'LayoutAnimation.configureNext');
55-
RCTUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError);
56-
},
57-
create(duration, type, creationProp) {
58-
return {
59-
duration,
88+
configureNext,
89+
create,
90+
Types,
91+
Properties,
92+
configChecker: configChecker,
93+
Presets: {
94+
easeInEaseOut: create(
95+
0.3, Types.easeInEaseOut, Properties.opacity
96+
),
97+
linear: create(
98+
0.5, Types.linear, Properties.opacity
99+
),
100+
spring: {
101+
duration: 0.7,
60102
create: {
61-
type,
62-
property: creationProp,
103+
type: Types.linear,
104+
property: Properties.opacity,
63105
},
64106
update: {
65-
type,
107+
type: Types.spring,
108+
springDamping: 0.4,
66109
},
67-
};
68-
},
69-
Types: Types,
70-
Properties: Properties,
71-
configChecker: configChecker,
72-
};
73-
74-
LayoutAnimation.Presets = {
75-
easeInEaseOut: LayoutAnimation.create(
76-
0.3, Types.easeInEaseOut, Properties.opacity
77-
),
78-
linear: LayoutAnimation.create(
79-
0.5, Types.linear, Properties.opacity
80-
),
81-
spring: {
82-
duration: 0.7,
83-
create: {
84-
type: Types.linear,
85-
property: Properties.opacity,
86-
},
87-
update: {
88-
type: Types.spring,
89-
springDamping: 0.4,
90110
},
91-
},
111+
}
92112
};
93113

94114
module.exports = LayoutAnimation;

Libraries/AppRegistry/AppRegistry.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule AppRegistry
10+
* @flow
1011
*/
1112
'use strict';
1213

@@ -21,6 +22,12 @@ if (__DEV__) {
2122

2223
var runnables = {};
2324

25+
type AppConfig = {
26+
appKey: string;
27+
component: ReactClass<any, any, any>;
28+
run?: Function;
29+
};
30+
2431
/**
2532
* `AppRegistry` is the JS entry point to running all React Native apps. App
2633
* root components should register themselves with
@@ -33,30 +40,31 @@ var runnables = {};
3340
* `require`d.
3441
*/
3542
var AppRegistry = {
36-
registerConfig: function(config) {
43+
registerConfig: function(config: Array<AppConfig>) {
3744
for (var i = 0; i < config.length; ++i) {
38-
if (config[i].run) {
39-
AppRegistry.registerRunnable(config[i].appKey, config[i].run);
45+
var appConfig = config[i];
46+
if (appConfig.run) {
47+
AppRegistry.registerRunnable(appConfig.appKey, appConfig.run);
4048
} else {
41-
AppRegistry.registerComponent(config[i].appKey, config[i].component);
49+
AppRegistry.registerComponent(appConfig.appKey, appConfig.component);
4250
}
4351
}
4452
},
4553

46-
registerComponent: function(appKey, getComponentFunc) {
54+
registerComponent: function(appKey: string, getComponentFunc: Function): string {
4755
runnables[appKey] = {
4856
run: (appParameters) =>
4957
renderApplication(getComponentFunc(), appParameters.initialProps, appParameters.rootTag)
5058
};
5159
return appKey;
5260
},
5361

54-
registerRunnable: function(appKey, func) {
62+
registerRunnable: function(appKey: string, func: Function): string {
5563
runnables[appKey] = {run: func};
5664
return appKey;
5765
},
5866

59-
runApplication: function(appKey, appParameters) {
67+
runApplication: function(appKey: string, appParameters: any): void {
6068
console.log(
6169
'Running application "' + appKey + '" with appParams: ' +
6270
JSON.stringify(appParameters) + '. ' +

Libraries/AppStateIOS/AppStateIOS.android.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule AppStateIOS
10+
* @flow
1011
*/
1112
'use strict';
1213

Libraries/AppStateIOS/AppStateIOS.ios.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*
99
* @providesModule AppStateIOS
10+
* @flow
1011
*/
1112
'use strict';
1213

0 commit comments

Comments
 (0)