diff --git a/.flowconfig b/.flowconfig index 3d5e14681dc..7bf00c596ed 100644 --- a/.flowconfig +++ b/.flowconfig @@ -42,10 +42,25 @@ # Ignore Website .*/website/.* +.*/node_modules/is-my-json-valid/test/.*\.json +.*/node_modules/iconv-lite/encodings/tables/.*\.json +.*/node_modules/y18n/test/.*\.json +.*/node_modules/spdx-license-ids/spdx-license-ids.json +.*/node_modules/spdx-exceptions/index.json +.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json +.*/node_modules/resolve/lib/core.json +.*/node_modules/jsonparse/samplejson/.*\.json +.*/node_modules/json5/test/.*\.json +.*/node_modules/ua-parser-js/test/.*\.json +.*/node_modules/builtin-modules/builtin-modules.json +.*/node_modules/binary-extensions/binary-extensions.json +.*/node_modules/url-regex/tlds.json + [include] [libs] Libraries/react-native/react-native-interface.js +flow/ [options] module.system=haste @@ -62,9 +77,9 @@ suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-1]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy [version] -0.21.0 +0.22.0 diff --git a/Examples/UIExplorer/ExampleTypes.js b/Examples/UIExplorer/ExampleTypes.js index ac9deaadfaf..691f4c6cf22 100644 --- a/Examples/UIExplorer/ExampleTypes.js +++ b/Examples/UIExplorer/ExampleTypes.js @@ -18,7 +18,7 @@ export type Example = { title: string, - render: () => ?ReactElement, + render: () => ?ReactElement, description?: string, platform?: string; }; diff --git a/Examples/UIExplorer/PointerEventsExample.js b/Examples/UIExplorer/PointerEventsExample.js index 735a5952d49..4ca8e9a164d 100644 --- a/Examples/UIExplorer/PointerEventsExample.js +++ b/Examples/UIExplorer/PointerEventsExample.js @@ -182,7 +182,7 @@ var BoxOnlyExample = React.createClass({ }); type ExampleClass = { - Component: ReactClass, + Component: ReactClass, title: string, description: string, }; diff --git a/Examples/UIExplorer/UIExplorerExampleList.js b/Examples/UIExplorer/UIExplorerExampleList.js index 07a07f381f4..4a81314c293 100644 --- a/Examples/UIExplorer/UIExplorerExampleList.js +++ b/Examples/UIExplorer/UIExplorerExampleList.js @@ -157,7 +157,7 @@ class UIExplorerExampleList extends React.Component { } } -function makeRenderable(example: any): ReactClass { +function makeRenderable(example: any): ReactClass { return example.examples ? createExamplePage(null, example) : example; diff --git a/Examples/UIExplorer/UIExplorerPage.js b/Examples/UIExplorer/UIExplorerPage.js index 2c74497a7fe..14bf2bed010 100644 --- a/Examples/UIExplorer/UIExplorerPage.js +++ b/Examples/UIExplorer/UIExplorerPage.js @@ -37,9 +37,9 @@ var UIExplorerPage = React.createClass({ var ContentWrapper; var wrapperProps = {}; if (this.props.noScroll) { - ContentWrapper = (View: ReactClass); + ContentWrapper = (View: ReactClass); } else { - ContentWrapper = (ScrollView: ReactClass); + ContentWrapper = (ScrollView: ReactClass); wrapperProps.automaticallyAdjustContentInsets = !this.props.title; wrapperProps.keyboardShouldPersistTaps = true; wrapperProps.keyboardDismissMode = 'interactive'; diff --git a/Examples/UIExplorer/createExamplePage.js b/Examples/UIExplorer/createExamplePage.js index 3d722029516..3d1d57898c6 100644 --- a/Examples/UIExplorer/createExamplePage.js +++ b/Examples/UIExplorer/createExamplePage.js @@ -29,7 +29,7 @@ var invariant = require('fbjs/lib/invariant'); import type { Example, ExampleModule } from 'ExampleTypes'; var createExamplePage = function(title: ?string, exampleModule: ExampleModule) - : ReactClass { + : ReactClass { invariant(!!exampleModule.examples, 'The module must have examples'); var ExamplePage = React.createClass({ diff --git a/Libraries/Animated/src/AnimatedImplementation.js b/Libraries/Animated/src/AnimatedImplementation.js index 8cfacf29860..20276c4cc6b 100644 --- a/Libraries/Animated/src/AnimatedImplementation.js +++ b/Libraries/Animated/src/AnimatedImplementation.js @@ -130,6 +130,7 @@ function _flush(rootNode: AnimatedValue): void { } } findAnimatedStyles(rootNode); + /* $FlowFixMe(site=react_native) */ animatedStyles.forEach(animatedStyle => animatedStyle.update()); } diff --git a/Libraries/AppRegistry/AppRegistry.js b/Libraries/AppRegistry/AppRegistry.js index 6077d866308..ab533b3acfb 100644 --- a/Libraries/AppRegistry/AppRegistry.js +++ b/Libraries/AppRegistry/AppRegistry.js @@ -25,7 +25,7 @@ if (__DEV__) { var runnables = {}; -type ComponentProvider = () => ReactClass; +type ComponentProvider = () => ReactClass; type AppConfig = { appKey: string; diff --git a/Libraries/NavigationExperimental/NavigationContainer.js b/Libraries/NavigationExperimental/NavigationContainer.js index c865ebe156d..9ebc8a925e3 100644 --- a/Libraries/NavigationExperimental/NavigationContainer.js +++ b/Libraries/NavigationExperimental/NavigationContainer.js @@ -15,7 +15,7 @@ var React = require('React'); var NavigationRootContainer = require('NavigationRootContainer'); function createNavigationContainer( - Component: ReactClass, + Component: ReactClass, ): ReactClass { class NavigationComponent extends React.Component { render() { diff --git a/Libraries/NavigationExperimental/NavigationLinearPanResponder.js b/Libraries/NavigationExperimental/NavigationLinearPanResponder.js index 904e73993a4..2318a70c6ca 100644 --- a/Libraries/NavigationExperimental/NavigationLinearPanResponder.js +++ b/Libraries/NavigationExperimental/NavigationLinearPanResponder.js @@ -12,7 +12,7 @@ const NavigationAbstractPanResponder = require('NavigationAbstractPanResponder') const clamp = require('clamp'); -import { +import type { NavigationActionCaller, NavigationLayout, NavigationPosition, diff --git a/Libraries/Network/NetInfo.js b/Libraries/Network/NetInfo.js index 5399be0250c..dd376ae6702 100644 --- a/Libraries/Network/NetInfo.js +++ b/Libraries/Network/NetInfo.js @@ -222,6 +222,7 @@ const NetInfo = { eventName: ChangeEventName, handler: Function ): void { + /* $FlowFixMe(site=react_native) */ const listener = _isConnectedSubscriptions.get(handler); NetInfo.removeEventListener( eventName, diff --git a/Libraries/ReactIOS/renderApplication.android.js b/Libraries/ReactIOS/renderApplication.android.js index b809ba08d0d..03191bbc037 100644 --- a/Libraries/ReactIOS/renderApplication.android.js +++ b/Libraries/ReactIOS/renderApplication.android.js @@ -107,7 +107,7 @@ var AppContainer = React.createClass({ }); function renderApplication( - RootComponent: ReactClass, + RootComponent: ReactClass

, initialProps: P, rootTag: any ) { diff --git a/Libraries/ReactIOS/renderApplication.ios.js b/Libraries/ReactIOS/renderApplication.ios.js index 2e37716cc13..c3e4f817804 100644 --- a/Libraries/ReactIOS/renderApplication.ios.js +++ b/Libraries/ReactIOS/renderApplication.ios.js @@ -66,7 +66,7 @@ var AppContainer = React.createClass({ }); function renderApplication( - RootComponent: ReactClass, + RootComponent: ReactClass

, initialProps: P, rootTag: any ) { diff --git a/Libraries/ReactIOS/verifyPropTypes.js b/Libraries/ReactIOS/verifyPropTypes.js index 07432eacb58..d284d60ec0a 100644 --- a/Libraries/ReactIOS/verifyPropTypes.js +++ b/Libraries/ReactIOS/verifyPropTypes.js @@ -13,7 +13,7 @@ var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes'); -export type ComponentInterface = ReactClass | { +export type ComponentInterface = ReactClass | { name?: string; displayName?: string; propTypes: Object; diff --git a/Libraries/ReactNative/createReactNativeComponentClass.js b/Libraries/ReactNative/createReactNativeComponentClass.js index 61a69a56060..199e268891a 100644 --- a/Libraries/ReactNative/createReactNativeComponentClass.js +++ b/Libraries/ReactNative/createReactNativeComponentClass.js @@ -27,7 +27,7 @@ type ReactNativeBaseComponentViewConfig = { */ var createReactNativeComponentClass = function( viewConfig: ReactNativeBaseComponentViewConfig -): ReactClass { +): ReactClass { var Constructor = function(element) { this._currentElement = element; diff --git a/flow/Map.js b/flow/Map.js new file mode 100644 index 00000000000..73c4e12caba --- /dev/null +++ b/flow/Map.js @@ -0,0 +1,31 @@ +// Copyright 2004-present Facebook. All Rights Reserved. +// @nolint + +// These annotations are copy/pasted from the built-in Flow definitions for +// Native Map. + +declare module "Map" { + // Use the name "MapPolyfill" so that we don't get confusing error + // messages about "Using Map instead of Map". + declare class MapPolyfill { + @@iterator(): Iterator<[K, V]>; + constructor(_: void): MapPolyfill; + constructor(_: null): MapPolyfill; + constructor(iterable: Array<[Key, Value]>): MapPolyfill; + constructor(iterable: Iterable<[Key, Value]>): MapPolyfill; + clear(): void; + delete(key: K): boolean; + entries(): Iterator<[K, V]>; + forEach(callbackfn: (value: V, index: K, map: MapPolyfill) => mixed, thisArg?: any): void; + get(key: K): V | void; + has(key: K): boolean; + keys(): Iterator; + set(key: K, value: V): MapPolyfill; + size: number; + values(): Iterator; + } + + // Don't "declare class exports" directly, otherwise in error messages our + // show up as "exports" instead of "Map" or "MapPolyfill". + declare var exports: typeof MapPolyfill; +} diff --git a/flow/Set.js b/flow/Set.js new file mode 100644 index 00000000000..7ca7dcd2dc1 --- /dev/null +++ b/flow/Set.js @@ -0,0 +1,26 @@ +// Copyright 2004-present Facebook. All Rights Reserved. +// @nolint + +// These annotations are copy/pasted from the built-in Flow definitions for +// Native Set. + +declare module "Set" { + // Use the name "SetPolyfill" so that we don't get confusing error + // messages about "Using Set instead of Set". + declare class SetPolyfill { + @@iterator(): Iterator; + add(value: T): SetPolyfill; + clear(): void; + delete(value: T): boolean; + entries(): Iterator<[T, T]>; + forEach(callbackfn: (value: T, index: T, set: SetPolyfill) => mixed, thisArg?: any): void; + has(value: T): boolean; + keys(): Iterator; + size: number; + values(): Iterator; + } + + // Don't "declare class exports" directly, otherwise in error messages our + // show up as "exports" instead of "Set" or "SetPolyfill". + declare var exports: typeof SetPolyfill; +} diff --git a/flow/react.js b/flow/react.js new file mode 100644 index 00000000000..f54cd42509e --- /dev/null +++ b/flow/react.js @@ -0,0 +1,3 @@ +// temporary patches for React.Component and React.Element +declare var ReactComponent: typeof React$Component; +declare var ReactElement: typeof React$Element;