diff --git a/.flowconfig b/.flowconfig index 82d818dcc..8a7e861c5 100644 --- a/.flowconfig +++ b/.flowconfig @@ -21,6 +21,7 @@ [libs] Libraries/react-native/react-native-interface.js +Examples/UIExplorer/ImageMocks.js [options] module.system=haste diff --git a/Examples/UIExplorer/ImageCapInsetsExample.js b/Examples/UIExplorer/ImageCapInsetsExample.js index 458cf7454..ab8838715 100644 --- a/Examples/UIExplorer/ImageCapInsetsExample.js +++ b/Examples/UIExplorer/ImageCapInsetsExample.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule ImageCapInsetsExample + * @flow */ 'use strict'; diff --git a/Examples/UIExplorer/ImageExample.js b/Examples/UIExplorer/ImageExample.js index 5fe6d580f..fd85e2c55 100644 --- a/Examples/UIExplorer/ImageExample.js +++ b/Examples/UIExplorer/ImageExample.js @@ -5,6 +5,8 @@ * 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 */ 'use strict'; diff --git a/Examples/UIExplorer/ImageMocks.js b/Examples/UIExplorer/ImageMocks.js new file mode 100644 index 000000000..7968cb3c3 --- /dev/null +++ b/Examples/UIExplorer/ImageMocks.js @@ -0,0 +1,35 @@ +/** + * Copyright 2004-present Facebook. 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 + */ +'use strict'; + +declare module 'image!story-background' { + declare var uri: string; + declare var isStatic: boolean; +} + +declare module 'image!uie_comment_highlighted' { + declare var uri: string; + declare var isStatic: boolean; +} + +declare module 'image!uie_comment_normal' { + declare var uri: string; + declare var isStatic: boolean; +} + +declare module 'image!uie_thumb_normal' { + declare var uri: string; + declare var isStatic: boolean; +} + +declare module 'image!uie_thumb_selected' { + declare var uri: string; + declare var isStatic: boolean; +} diff --git a/Examples/UIExplorer/MapViewExample.js b/Examples/UIExplorer/MapViewExample.js index 74c4f6533..22b2475a0 100644 --- a/Examples/UIExplorer/MapViewExample.js +++ b/Examples/UIExplorer/MapViewExample.js @@ -5,6 +5,8 @@ * 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 */ 'use strict'; @@ -188,7 +190,7 @@ exports.description = 'Base component to display maps'; exports.examples = [ { title: 'Map', - render() { return ; } + render(): ReactElement { return ; } }, { title: 'Map shows user location', diff --git a/Examples/UIExplorer/TabBarExample.js b/Examples/UIExplorer/TabBarExample.js index a38255ff4..793bfd309 100644 --- a/Examples/UIExplorer/TabBarExample.js +++ b/Examples/UIExplorer/TabBarExample.js @@ -5,6 +5,8 @@ * 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 */ 'use strict'; @@ -31,7 +33,7 @@ var TabBarExample = React.createClass({ }; }, - _renderContent: function(color, pageText) { + _renderContent: function(color: string, pageText: string) { return ( {pageText} diff --git a/Examples/UIExplorer/createExamplePage.js b/Examples/UIExplorer/createExamplePage.js index 8700512a7..2bc50b15e 100644 --- a/Examples/UIExplorer/createExamplePage.js +++ b/Examples/UIExplorer/createExamplePage.js @@ -7,6 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule createExamplePage + * @flow */ 'use strict'; @@ -16,7 +17,19 @@ var UIExplorerPage = require('./UIExplorerPage'); var invariant = require('invariant'); -var createExamplePage = function(title, exampleModule) { +class Example extends React.Component { + title: string; + description: string; +} + +type ExampleModule = { + title: string; + description: string; + examples: Array; +}; + +var createExamplePage = function(title: ?string, exampleModule: ExampleModule) + : ReactClass { invariant(!!exampleModule.examples, 'The module must have examples'); var ExamplePage = React.createClass({ @@ -31,15 +44,17 @@ var createExamplePage = function(title, exampleModule) { var originalRenderComponent = React.renderComponent; var originalRender = React.render; var renderedComponent; - React.render = React.renderComponent = function(element, container) { + // TODO remove typecasts when Flow bug #6560135 is fixed + // and workaround is removed from react-native.js + (React: Object).render = (React: Object).renderComponent = function(element, container) { renderedComponent = element; }; var result = example.render(null); if (result) { renderedComponent = result; } - React.renderComponent = originalRenderComponent; - React.render = originalRender; + (React: Object).renderComponent = originalRenderComponent; + (React: Object).render = originalRender; return (