Skip to content

Resolve react flow definitions #5489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Libraries/react-native/react-native-interface.js
[options]
module.system=haste

esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

munge_underscores=true

module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
Expand Down
3 changes: 3 additions & 0 deletions Examples/2048/Game2048.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Board extends React.Component {
}

class Tile extends React.Component {
state: any;

static _getPosition(index): number {
return BOARD_PADDING + (index * (CELL_SIZE + CELL_MARGIN * 2) + CELL_MARGIN);
}
Expand Down Expand Up @@ -147,6 +149,7 @@ class GameEndOverlay extends React.Component {
class Game2048 extends React.Component {
startX: number;
startY: number;
state: any;

constructor(props: {}) {
super(props);
Expand Down
6 changes: 5 additions & 1 deletion Examples/UIExplorer/AlertIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports.examples = [{
},
{
title: 'Prompt Options',
render(): React.Component {
render(): ReactElement {
return <PromptOptions />;
}
},
Expand Down Expand Up @@ -85,9 +85,13 @@ exports.examples = [{
}];

class PromptOptions extends React.Component {
state: any;
customButtons: Array<Object>;

constructor(props) {
super(props);

// $FlowFixMe this seems to be a Flow bug, `saveResponse` is defined below
this.saveResponse = this.saveResponse.bind(this);

this.customButtons = [{
Expand Down
4 changes: 4 additions & 0 deletions Examples/UIExplorer/AnimatedExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ exports.examples = [
'mounts.',
render: function() {
class FadeInView extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {
Expand Down Expand Up @@ -66,6 +68,8 @@ exports.examples = [
}
}
class FadeInExample extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {
Expand Down
15 changes: 11 additions & 4 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ var CIRCLE_MARGIN = 18;
var NUM_CIRCLES = 30;

class Circle extends React.Component {
state: any;
props: any;
longTimer: number;

_onLongPress: () => void;
_toggleIsActive: () => void;
constructor(props: Object): void {
Expand Down Expand Up @@ -156,6 +160,13 @@ class Circle extends React.Component {
}

class AnExApp extends React.Component {
state: any;
props: any;

static title = 'Animated - Gratuitous App';
static description = 'Bunch of Animations - tap a circle to ' +
'open a view with more animations, or longPress and drag to reorder circles.';

_onMove: (position: Point) => void;
constructor(props: any): void {
super(props);
Expand Down Expand Up @@ -266,10 +277,6 @@ function moveToClosest({activeKey, keys, restLayouts}, position) {
}
}

AnExApp.title = 'Animated - Gratuitous App';
AnExApp.description = 'Bunch of Animations - tap a circle to ' +
'open a view with more animations, or longPress and drag to reorder circles.';

var styles = StyleSheet.create({
container: {
flex: 1,
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExBobble.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var BOBBLE_SPOTS = [...Array(NUM_BOBBLES)].map((_, i) => { // static positions
});

class AnExBobble extends React.Component {
state: any;

constructor(props: Object) {
super(props);
this.state = {};
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExChained.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var {
} = React;

class AnExChained extends React.Component {
state: any;

constructor(props: Object) {
super(props);
this.state = {
Expand Down
8 changes: 2 additions & 6 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* @providesModule AnExScroll
* @flow
*/
'use strict';

Expand All @@ -26,12 +27,7 @@ var {
} = React;

class AnExScroll extends React.Component {
constructor(props) {
super(props);
this.state = {
scrollX: new Animated.Value(0),
};
}
state: any = { scrollX: new Animated.Value(0) };

render() {
var width = this.props.panelWidth;
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ var AnExScroll = require('./AnExScroll');
var AnExTilt = require('./AnExTilt');

class AnExSet extends React.Component {
state: any;

constructor(props: Object) {
super(props);
function randColor() {
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/AnimatedGratuitousApp/AnExTilt.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var {
} = React;

class AnExTilt extends React.Component {
state: any;

constructor(props: Object) {
super(props);
this.state = {
Expand Down
3 changes: 2 additions & 1 deletion Examples/UIExplorer/ImageEditingExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ type ImageCropData = {
offset: ImageOffset;
size: ImageSize;
displaySize?: ?ImageSize;
resizeMode?: ?any;
resizeMode?: ?any;
};

class SquareImageCropper extends React.Component {
state: any;
_isMounted: boolean;
_transformData: ImageCropData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ const NavigationExampleTabBar = require('./NavigationExampleTabBar');

import type {NavigationParentState} from 'NavigationStateUtils';

type Action = {
isExitAction?: boolean,
};

const ExampleExitAction = () => ({
isExitAction: true,
});
ExampleExitAction.match = (action) => (
ExampleExitAction.match = (action: Action) => (
action && action.isExitAction === true
);

Expand Down Expand Up @@ -196,6 +200,8 @@ class ExampleTabScreen extends React.Component {
ExampleTabScreen = NavigationContainer.create(ExampleTabScreen);

class NavigationCompositionExample extends React.Component {
navRootContainer: NavigationRootContainer;

render() {
return (
<NavigationRootContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ function isGameOver(gameString: string): boolean {
}

class Cell extends React.Component {
props: any;
cellStyle() {
switch (this.props.player) {
case 'X':
Expand Down Expand Up @@ -207,6 +208,9 @@ function GameReducer(lastGame: ?string, action: Object): string {
}

class NavigationTicTacToeExample extends React.Component {
static GameView = TicTacToeGame;
static GameReducer = GameReducer;
static GameActions = GameActions;
render() {
return (
<NavigationRootContainer
Expand All @@ -222,9 +226,6 @@ class NavigationTicTacToeExample extends React.Component {
);
}
}
NavigationTicTacToeExample.GameView = TicTacToeGame;
NavigationTicTacToeExample.GameReducer = GameReducer;
NavigationTicTacToeExample.GameActions = GameActions;

const styles = StyleSheet.create({
closeButton: {
Expand Down
8 changes: 5 additions & 3 deletions Examples/UIExplorer/PushNotificationIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class NotificationExample extends React.Component {
}

class NotificationPermissionExample extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {permissions: null};
Expand Down Expand Up @@ -126,7 +128,7 @@ exports.description = 'Apple PushNotification and badge value';
exports.examples = [
{
title: 'Badge Number',
render(): React.Component {
render(): ReactElement {
PushNotificationIOS.requestPermissions();

return (
Expand All @@ -145,13 +147,13 @@ exports.examples = [
},
{
title: 'Push Notifications',
render(): React.Component {
render(): ReactElement {
return <NotificationExample />;
}
},
{
title: 'Notifications Permissions',
render(): React.Component {
render(): ReactElement {
return <NotificationPermissionExample />;
}
}];
4 changes: 2 additions & 2 deletions Examples/UIExplorer/RCTRootViewIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ exports.description = 'Examples that show useful methods when embedding React Na
exports.examples = [
{
title: 'Updating app properties in runtime',
render(): React.Component {
render(): ReactElement {
return (
<AppPropertiesUpdateExample/>
);
},
},
{
title: 'RCTRootView\'s size flexibility',
render(): React.Component {
render(): ReactElement {
return (
<RootViewSizeFlexibilityExample/>
);
Expand Down
1 change: 1 addition & 0 deletions Examples/UIExplorer/RootViewSizeFlexibilityExampleApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const {
} = React;

class RootViewSizeFlexibilityExampleApp extends React.Component {
state: any;

constructor(props: {toggled: boolean}) {
super(props);
Expand Down
8 changes: 8 additions & 0 deletions Examples/UIExplorer/TextInputExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ var TextEventsExample = React.createClass({
});

class AutoExpandingTextInput extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {text: '', height: 0};
Expand All @@ -120,6 +122,8 @@ class AutoExpandingTextInput extends React.Component {
}

class RewriteExample extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {text: ''};
Expand Down Expand Up @@ -149,6 +153,8 @@ class RewriteExample extends React.Component {
}

class RewriteExampleInvalidCharacters extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {text: ''};
Expand All @@ -170,6 +176,8 @@ class RewriteExampleInvalidCharacters extends React.Component {
}

class TokenizedTextExample extends React.Component {
state: any;

constructor(props) {
super(props);
this.state = {text: 'Hello #World'};
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/XHRExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var XHRExampleHeaders = require('./XHRExampleHeaders');
var XHRExampleFetch = require('./XHRExampleFetch');

class Downloader extends React.Component {
state: any;

xhr: XMLHttpRequest;
cancelled: boolean;
Expand Down Expand Up @@ -120,6 +121,7 @@ class Downloader extends React.Component {
var PAGE_SIZE = 20;

class FormUploader extends React.Component {
state: any;

_isMounted: boolean;
_fetchRandomPhoto: () => void;
Expand Down
3 changes: 3 additions & 0 deletions Examples/UIExplorer/XHRExampleCookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var {
var RCTNetworking = require('RCTNetworking');

class XHRExampleCookies extends React.Component {
state: any;
cancelled: boolean;

constructor(props: any) {
super(props);
this.cancelled = false;
Expand Down
2 changes: 2 additions & 0 deletions Examples/UIExplorer/XHRExampleFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var {


class XHRExampleFetch extends React.Component {
state: any;
responseURL: ?string;

constructor(props: any) {
super(props);
Expand Down
1 change: 1 addition & 0 deletions Examples/UIExplorer/createExamplePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var createExamplePage = function(title: ?string, exampleModule: ExampleModule)
// Hack warning: This is a hack because the www UI explorer requires
// renderComponent to be called.
var originalRender = React.render;
// $FlowFixMe React.renderComponent was deprecated in 0.12, should this be React.render?
var originalRenderComponent = React.renderComponent;
var originalIOSRender = ReactNative.render;
var originalIOSRenderComponent = ReactNative.renderComponent;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/react-native/react-native.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//
// var ReactNative = {...require('React'), /* additions */}
//
var ReactNative = Object.assign(Object.create(require('React')), {
var ReactNative = Object.assign(Object.create(require('react')), {
// Components
ActivityIndicatorIOS: require('ActivityIndicatorIOS'),
ART: require('ReactNativeART'),
Expand Down