Set up Flow - Yay! (#6682)
This just configures flow to be checked and fixes our existing Flow typed files. Possible enhancements: Export .js.flow declarations from the build. Unclear whether this will be a supported workflow in the future or not, so let's wait on that. We should fail builds and CI on Flow errors. Ideally we should lint for Flow style guides (like no space before colon).
Sebastian Markbåge committed
May 3, 2016 at 14:37 UTC
771d938fc01b2f18e15b4c755b67896bbf5a1da9
7 files changed
+105
-6
.flowconfig
new
+34
@@ -0,0 +1,34 @@
1
+[ignore]
2
+
3
+.*/build/.*
4
+.*/node_modules/y18n/.*
5
+.*/__mocks__/.*
6
+.*/__tests__/.*
7
+
8
+# Ignore Docs
9
+.*/docs/.*
10
+
11
+[include]
12
+
13
+[libs]
14
+./node_modules/fbjs/flow/lib
15
+./flow
16
+
17
+[options]
18
+module.system=haste
19
+
20
+esproposal.class_static_fields=enable
21
+esproposal.class_instance_fields=enable
22
+
23
+munge_underscores=false
24
+
25
+suppress_type=$FlowIssue
26
+suppress_type=$FlowFixMe
27
+suppress_type=$FixMe
28
+
29
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)
30
+suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)? #[0-9]+
31
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
32
+
33
+[version]
34
+0.24.0
flow/environment.js
new
+20
@@ -0,0 +1,20 @@
1
+/**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @flow
10
+ */
11
+
12
+/* eslint-disable */
13
+
14
+declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
15
+ inject: ?((stuff: Object) => void)
16
+};*/
17
+
18
+// temporary patches for React.Component and React.Element
19
+declare var ReactComponent: typeof React$Component;
20
+declare var ReactElement: typeof React$Element;
flow/react-native-host-hooks.js
new
+44
@@ -0,0 +1,44 @@
1
+/**
2
+ * Copyright (c) 2015-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ * @flow
10
+ */
11
+
12
+/* eslint-disable */
13
+
14
+declare module 'deepDiffer' {
15
+ declare function exports(one: any, two: any): bool;
16
+}
17
+declare module 'deepFreezeAndThrowOnMutationInDev' {
18
+ declare function exports<T>(obj : T) : T;
19
+}
20
+declare module 'flattenStyle' { }
21
+declare module 'InitializeJavaScriptAppEngine' { }
22
+declare module 'RCTEventEmitter' {
23
+ declare function register() : void;
24
+}
25
+declare module 'TextInputState' {
26
+ declare function blurTextInput(object : any) : void;
27
+ declare function focusTextInput(object : any) : void;
28
+}
29
+declare module 'UIManager' {
30
+ declare var customBubblingEventTypes : Object;
31
+ declare var customDirectEventTypes : Object;
32
+ declare function createView() : void;
33
+ declare function manageChildren() : void;
34
+ declare function measure() : void;
35
+ declare function measureInWindow() : void;
36
+ declare function measureLayout() : void;
37
+ declare function removeRootView() : void;
38
+ declare function removeSubviewsFromContainerWithID() : void;
39
+ declare function replaceExistingNonRootView() : void;
40
+ declare function setChildren() : void;
41
+ declare function setChildren() : void;
42
+ declare function updateView() : void;
43
+}
44
+declare module 'View' { }
src/renderers/native/ReactNativeAttributePayload.js
+1
@@ -394,6 +394,7 @@ function diffProperties(
394
// default: fallthrough case when nested properties are defined
395
removedKeys = null;
396
removedKeyCount = 0;
397
+ // $FlowFixMe - We think that attributeConfig is not CustomAttributeConfiguration at this point so we assume it must be AttributeConfiguration.
398
updatePayload = diffNestedProperty(
399
updatePayload,
400
prevProp,
src/renderers/native/ReactNativeBridgeEventPlugin.js
+4
-4
@@ -43,10 +43,10 @@ var ReactNativeBridgeEventPlugin = {
43
* @see {EventPluginHub.extractEvents}
44
*/
45
extractEvents: function(
46
- topLevelType,
47
- targetInst,
48
- nativeEvent,
49
- nativeEventTarget
46
+ topLevelType: string,
47
+ targetInst: Object,
48
+ nativeEvent: Event,
49
+ nativeEventTarget: Object
50
): ?Object {
51
var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
52
var directDispatchConfig = customDirectEventTypes[topLevelType];
src/renderers/native/ReactNativeContainerInfo.js
+1
-1
@@ -11,7 +11,7 @@
11
*/
12
'use strict';
13
14
-function ReactNativeContainerInfo(tag) {
14
+function ReactNativeContainerInfo(tag: number) {
15
var info = {
16
_tag: tag,
17
};
src/renderers/native/ReactNativeMount.js
+1
-1
@@ -233,7 +233,7 @@ var ReactNativeMount = {
233
*/
234
unmountComponentFromNode: function(
235
instance: ReactComponent,
236
- containerID: string
236
+ containerID: number
237
) {
238
// Call back into native to remove all of the subviews from this container
239
ReactReconciler.unmountComponent(instance);