[Flow] v0.11.0 cleaning - Part 14 (react-native-github)

This commit is contained in:
Gabe Levi 2015-05-12 14:22:22 -07:00 committed by Christopher Chedeau
parent 4a137aa840
commit 184bb1151a
8 changed files with 62 additions and 23 deletions

View File

@ -150,7 +150,7 @@ class Game2048 extends React.Component {
startX: number;
startY: number;
constructor(props) {
constructor(props: {}) {
super(props);
this.state = {
board: new GameBoard(),

View File

@ -0,0 +1,30 @@
/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule ExampleTypes
* @flow
*/
export type Example = {
title: string,
render: () => ?ReactElement<any, any, any>,
description?: string,
};
export type ExampleModule = {
title: string;
description: string;
examples: Array<Example>;
external?: bool;
};

View File

@ -168,7 +168,7 @@ var MapViewExample = React.createClass({
/>
<MapRegionInput
onChange={this._onRegionInputChanged}
region={this.state.mapRegionInput}
region={this.state.mapRegionInput || undefined}
/>
</View>
);

View File

@ -181,7 +181,13 @@ var BoxOnlyExample = React.createClass({
}
});
var exampleClasses = [
type ExampleClass = {
Component: ReactClass<any, any, any>,
title: string,
description: string,
};
var exampleClasses: Array<ExampleClass> = [
{
Component: NoneExample,
title: '`none`',

View File

@ -30,6 +30,8 @@ var {
var { TestModule } = React.addons;
var Settings = require('Settings');
import type { Example, ExampleModule } from 'ExampleTypes';
var createExamplePage = require('./createExamplePage');
var COMPONENTS = [
@ -107,9 +109,17 @@ COMPONENTS.concat(APIS).forEach((Example) => {
}
});
class UIExplorerList extends React.Component {
type Props = {
navigator: Array<{title: string, component: ReactClass<any,any,any>}>,
onExternalExampleRequested: Function,
};
constructor(props) {
class UIExplorerList extends React.Component {
props: Props;
constructor(props: Props) {
super(props);
this.state = {
dataSource: ds.cloneWithRowsAndSections({
@ -149,7 +159,7 @@ class UIExplorerList extends React.Component {
);
}
_renderSectionHeader(data, section) {
_renderSectionHeader(data: any, section: string) {
return (
<View style={styles.sectionHeader}>
<Text style={styles.sectionHeaderTitle}>
@ -159,7 +169,7 @@ class UIExplorerList extends React.Component {
);
}
_renderRow(example, i) {
_renderRow(example: ExampleModule, i: number) {
return (
<View key={i}>
<TouchableHighlight onPress={() => this._onPressRow(example)}>
@ -177,7 +187,7 @@ class UIExplorerList extends React.Component {
);
}
_search(text) {
_search(text: mixed) {
var regex = new RegExp(text, 'i');
var filter = (component) => regex.test(component.title);
@ -191,7 +201,7 @@ class UIExplorerList extends React.Component {
Settings.set({searchText: text});
}
_onPressRow(example) {
_onPressRow(example: ExampleModule) {
if (example.external) {
this.props.onExternalExampleRequested(example);
return;

View File

@ -23,16 +23,7 @@ var UIExplorerPage = require('./UIExplorerPage');
var invariant = require('invariant');
class Example extends React.Component {
title: string;
description: string;
}
type ExampleModule = {
title: string;
description: string;
examples: Array<Example>;
};
import type { Example, ExampleModule } from 'ExampleTypes';
var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
: ReactClass<any, any, any> {
@ -44,7 +35,7 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
description: exampleModule.description,
},
getBlock: function(example, i) {
getBlock: function(example: Example, i) {
// Hack warning: This is a hack because the www UI explorer requires
// renderComponent to be called.
var originalRender = React.render;

View File

@ -92,6 +92,8 @@ var getPhotosReturnChecker = createStrictShapeTypeChecker({
});
class CameraRoll {
static GroupTypesOptions: Array<string>;
/**
* Saves the image with tag `tag` to the camera roll.
*

View File

@ -67,9 +67,9 @@ class PixelRatio {
static getPixelSizeForLayoutSize(layoutSize: number): number {
return Math.round(layoutSize * PixelRatio.get());
}
// No-op for iOS, but used on the web. Should not be documented.
static startDetecting() {}
}
// No-op for iOS, but used on the web. Should not be documented.
PixelRatio.startDetecting = function() {};
module.exports = PixelRatio;