Skip to content

Commit

Permalink
Set up Flow - Yay! (#6682)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
sebmarkbage committed May 3, 2016
1 parent 48f4684 commit 771d938
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 6 deletions.
34 changes: 34 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[ignore]

.*/build/.*
.*/node_modules/y18n/.*
.*/__mocks__/.*
.*/__tests__/.*

# Ignore Docs
.*/docs/.*

[include]

[libs]
./node_modules/fbjs/flow/lib
./flow

[options]
module.system=haste

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

munge_underscores=false

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

[version]
0.24.0
20 changes: 20 additions & 0 deletions flow/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/

/* eslint-disable */

declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{
inject: ?((stuff: Object) => void)
};*/

// temporary patches for React.Component and React.Element
declare var ReactComponent: typeof React$Component;
declare var ReactElement: typeof React$Element;
44 changes: 44 additions & 0 deletions flow/react-native-host-hooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/

/* eslint-disable */

declare module 'deepDiffer' {
declare function exports(one: any, two: any): bool;
}
declare module 'deepFreezeAndThrowOnMutationInDev' {
declare function exports<T>(obj : T) : T;
}
declare module 'flattenStyle' { }
declare module 'InitializeJavaScriptAppEngine' { }
declare module 'RCTEventEmitter' {
declare function register() : void;
}
declare module 'TextInputState' {
declare function blurTextInput(object : any) : void;
declare function focusTextInput(object : any) : void;
}
declare module 'UIManager' {
declare var customBubblingEventTypes : Object;
declare var customDirectEventTypes : Object;
declare function createView() : void;
declare function manageChildren() : void;
declare function measure() : void;
declare function measureInWindow() : void;
declare function measureLayout() : void;
declare function removeRootView() : void;
declare function removeSubviewsFromContainerWithID() : void;
declare function replaceExistingNonRootView() : void;
declare function setChildren() : void;
declare function setChildren() : void;
declare function updateView() : void;
}
declare module 'View' { }
1 change: 1 addition & 0 deletions src/renderers/native/ReactNativeAttributePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ function diffProperties(
// default: fallthrough case when nested properties are defined
removedKeys = null;
removedKeyCount = 0;
// $FlowFixMe - We think that attributeConfig is not CustomAttributeConfiguration at this point so we assume it must be AttributeConfiguration.
updatePayload = diffNestedProperty(
updatePayload,
prevProp,
Expand Down
8 changes: 4 additions & 4 deletions src/renderers/native/ReactNativeBridgeEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ var ReactNativeBridgeEventPlugin = {
* @see {EventPluginHub.extractEvents}
*/
extractEvents: function(
topLevelType,
targetInst,
nativeEvent,
nativeEventTarget
topLevelType: string,
targetInst: Object,
nativeEvent: Event,
nativeEventTarget: Object
): ?Object {
var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
var directDispatchConfig = customDirectEventTypes[topLevelType];
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/ReactNativeContainerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
'use strict';

function ReactNativeContainerInfo(tag) {
function ReactNativeContainerInfo(tag: number) {
var info = {
_tag: tag,
};
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/native/ReactNativeMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ var ReactNativeMount = {
*/
unmountComponentFromNode: function(
instance: ReactComponent,
containerID: string
containerID: number
) {
// Call back into native to remove all of the subviews from this container
ReactReconciler.unmountComponent(instance);
Expand Down

0 comments on commit 771d938

Please sign in to comment.