diff --git a/IntegrationTests/AppEventsTest.js b/IntegrationTests/AppEventsTest.js index a109f42e4c35c6..4bc0b0649c16fa 100644 --- a/IntegrationTests/AppEventsTest.js +++ b/IntegrationTests/AppEventsTest.js @@ -36,7 +36,7 @@ class AppEventsTest extends React.Component<{}, State> { this.setState({sent: event}); } - receiveEvent = (event: any) => { + receiveEvent: (event: any) => void = (event: any) => { if (deepDiffer(event.data, TEST_PAYLOAD)) { throw new Error('Received wrong event: ' + JSON.stringify(event)); } @@ -46,7 +46,7 @@ class AppEventsTest extends React.Component<{}, State> { }); }; - render() { + render(): React.Node { return ( {JSON.stringify(this.state, null, ' ')} diff --git a/IntegrationTests/AsyncStorageTest.js b/IntegrationTests/AsyncStorageTest.js index d22a611064cf53..5df923c7f670ea 100644 --- a/IntegrationTests/AsyncStorageTest.js +++ b/IntegrationTests/AsyncStorageTest.js @@ -172,7 +172,7 @@ function testOptimizedMultiGet() { } class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> { - state = { + state: any | $TEMPORARY$object<{|done: boolean, messages: string|}> = { messages: 'Initializing...', done: false, }; @@ -189,7 +189,7 @@ class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> { AsyncStorage.clear(testSetAndGet); } - render() { + render(): React.Node { return ( diff --git a/IntegrationTests/ImageCachePolicyTest.js b/IntegrationTests/ImageCachePolicyTest.js index 0dae9812cf6e24..d25e6c2b86ede3 100644 --- a/IntegrationTests/ImageCachePolicyTest.js +++ b/IntegrationTests/ImageCachePolicyTest.js @@ -36,9 +36,9 @@ type State = { }; class ImageCachePolicyTest extends React.Component { - state = {}; + state: $FlowFixMe | $TEMPORARY$object<{||}> = {}; - shouldComponentUpdate(nextProps: Props, nextState: State) { + shouldComponentUpdate(nextProps: Props, nextState: State): boolean { const results: Array = TESTS.map(x => nextState[x]); if (!results.includes(undefined)) { @@ -56,7 +56,7 @@ class ImageCachePolicyTest extends React.Component { this.setState({[name]: pass}); } - render() { + render(): React.Node { return ( Hello diff --git a/IntegrationTests/ImageSnapshotTest.js b/IntegrationTests/ImageSnapshotTest.js index c4ffaae51c2ec4..495423ae006340 100644 --- a/IntegrationTests/ImageSnapshotTest.js +++ b/IntegrationTests/ImageSnapshotTest.js @@ -22,11 +22,11 @@ class ImageSnapshotTest extends React.Component<{}> { } } - done = (success: boolean) => { + done: (success: boolean) => void = (success: boolean) => { TestModule.markTestPassed(success); }; - render() { + render(): React.Node { return ( { - state = { + state: State = { done: false, }; @@ -38,7 +39,7 @@ class IntegrationTestHarnessTest extends React.Component { } } - runTest = () => { + runTest: () => void = () => { if (this.props.shouldThrow) { throw new Error('Throwing error because shouldThrow'); } @@ -52,7 +53,7 @@ class IntegrationTestHarnessTest extends React.Component { }); }; - render() { + render(): React.Node { return ( diff --git a/IntegrationTests/LayoutEventsTest.js b/IntegrationTests/LayoutEventsTest.js index 7be877f962456b..42def2c419b980 100644 --- a/IntegrationTests/LayoutEventsTest.js +++ b/IntegrationTests/LayoutEventsTest.js @@ -58,7 +58,7 @@ class LayoutEventsTest extends React.Component { this.setState({viewStyle: {margin: 60}}); } - addWrapText = () => { + addWrapText: () => void = () => { debug('addWrapText invoked'); this.setState( {extraText: ' And a bunch more text to wrap around a few lines.'}, @@ -66,14 +66,14 @@ class LayoutEventsTest extends React.Component { ); }; - changeContainer = () => { + changeContainer: () => void = () => { debug('changeContainer invoked'); this.setState({containerStyle: {width: 280}}, () => this.checkLayout(TestModule.markTestCompleted), ); }; - checkLayout = (next?: ?() => void) => { + checkLayout: (next?: ?() => void) => void = (next?: ?() => void) => { const view = this._view; const txt = this._txt; const img = this._img; @@ -117,22 +117,22 @@ class LayoutEventsTest extends React.Component { } } - onViewLayout = (e: LayoutEvent) => { + onViewLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => { debug('received view layout event\n', e.nativeEvent); this.setState({viewLayout: e.nativeEvent.layout}, this.checkLayout); }; - onTextLayout = (e: LayoutEvent) => { + onTextLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => { debug('received text layout event\n', e.nativeEvent); this.setState({textLayout: e.nativeEvent.layout}, this.checkLayout); }; - onImageLayout = (e: LayoutEvent) => { + onImageLayout: (e: LayoutEvent) => void = (e: LayoutEvent) => { debug('received image layout event\n', e.nativeEvent); this.setState({imageLayout: e.nativeEvent.layout}, this.checkLayout); }; - render() { + render(): React.Node { const viewStyle = [styles.view, this.state.viewStyle]; const textLayout = this.state.textLayout || {width: '?', height: '?'}; const imageLayout = this.state.imageLayout || {x: '?', y: '?'}; diff --git a/IntegrationTests/PromiseTest.js b/IntegrationTests/PromiseTest.js index c36d3beb017b69..b35c971fc34816 100644 --- a/IntegrationTests/PromiseTest.js +++ b/IntegrationTests/PromiseTest.js @@ -16,10 +16,10 @@ const {View} = ReactNative; const {TestModule} = ReactNative.NativeModules; class PromiseTest extends React.Component<{}> { - shouldResolve = false; - shouldReject = false; - shouldSucceedAsync = false; - shouldThrowAsync = false; + shouldResolve: boolean = false; + shouldReject: boolean = false; + shouldSucceedAsync: boolean = false; + shouldThrowAsync: boolean = false; componentDidMount() { Promise.all([ @@ -37,19 +37,19 @@ class PromiseTest extends React.Component<{}> { ); } - testShouldResolve = () => { + testShouldResolve: () => any = () => { return TestModule.shouldResolve() .then(() => (this.shouldResolve = true)) .catch(() => (this.shouldResolve = false)); }; - testShouldReject = () => { + testShouldReject: () => any = () => { return TestModule.shouldReject() .then(() => (this.shouldReject = false)) .catch(() => (this.shouldReject = true)); }; - testShouldSucceedAsync = async (): Promise => { + testShouldSucceedAsync: () => Promise = async (): Promise => { try { await TestModule.shouldResolve(); this.shouldSucceedAsync = true; @@ -58,7 +58,7 @@ class PromiseTest extends React.Component<{}> { } }; - testShouldThrowAsync = async (): Promise => { + testShouldThrowAsync: () => Promise = async (): Promise => { try { await TestModule.shouldReject(); this.shouldThrowAsync = false; diff --git a/IntegrationTests/ReactContentSizeUpdateTest.js b/IntegrationTests/ReactContentSizeUpdateTest.js index ad87bb6ed42f08..47373d6f2a8978 100644 --- a/IntegrationTests/ReactContentSizeUpdateTest.js +++ b/IntegrationTests/ReactContentSizeUpdateTest.js @@ -10,9 +10,9 @@ 'use strict'; +const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter'); const React = require('react'); const ReactNative = require('react-native'); -const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter'); const {View} = ReactNative; @@ -35,7 +35,7 @@ class ReactContentSizeUpdateTest extends React.Component { _timeoutID: ?TimeoutID = null; _subscription: ?EmitterSubscription = null; - state = { + state: State = { height: reactViewHeight, width: reactViewWidth, }; @@ -70,7 +70,9 @@ class ReactContentSizeUpdateTest extends React.Component { }); } - rootViewDidChangeIntrinsicSize = (intrinsicSize: State) => { + rootViewDidChangeIntrinsicSize: (intrinsicSize: State) => void = ( + intrinsicSize: State, + ) => { if ( intrinsicSize.height === newReactViewHeight && intrinsicSize.width === newReactViewWidth @@ -79,7 +81,7 @@ class ReactContentSizeUpdateTest extends React.Component { } }; - render() { + render(): React.Node { return ( ); diff --git a/IntegrationTests/SimpleSnapshotTest.js b/IntegrationTests/SimpleSnapshotTest.js index 6ebf24fd25ac3a..90cb3f1e17c475 100644 --- a/IntegrationTests/SimpleSnapshotTest.js +++ b/IntegrationTests/SimpleSnapshotTest.js @@ -12,6 +12,7 @@ const React = require('react'); const ReactNative = require('react-native'); + const requestAnimationFrame = require('fbjs/lib/requestAnimationFrame'); const {StyleSheet, View} = ReactNative; @@ -25,11 +26,11 @@ class SimpleSnapshotTest extends React.Component<{}> { requestAnimationFrame(() => TestModule.verifySnapshot(this.done)); } - done = (success: boolean) => { + done: (success: boolean) => void = (success: boolean) => { TestModule.markTestPassed(success); }; - render() { + render(): React.Node { return ( diff --git a/IntegrationTests/SizeFlexibilityUpdateTest.js b/IntegrationTests/SizeFlexibilityUpdateTest.js index 2da24f0b920f9a..419083c57a319a 100644 --- a/IntegrationTests/SizeFlexibilityUpdateTest.js +++ b/IntegrationTests/SizeFlexibilityUpdateTest.js @@ -10,9 +10,9 @@ 'use strict'; +const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter'); const React = require('react'); const ReactNative = require('react-native'); -const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter'); const {View} = ReactNative; const {TestModule} = ReactNative.NativeModules; @@ -46,15 +46,15 @@ class SizeFlexibilityUpdateTest extends React.Component { } } - markPassed = () => { + markPassed: () => void = () => { TestModule.markTestPassed(true); finalState = true; }; - rootViewDidChangeIntrinsicSize = (intrinsicSize: { - width: number, + rootViewDidChangeIntrinsicSize: (intrinsicSize: { height: number, - }) => { + width: number, + }) => void = (intrinsicSize: {width: number, height: number}) => { if (finalState) { // If a test reaches its final state, it is not expected to do anything more TestModule.markTestPassed(false); @@ -99,7 +99,7 @@ class SizeFlexibilityUpdateTest extends React.Component { } }; - render() { + render(): React.Node { return ; } } diff --git a/IntegrationTests/TimersTest.js b/IntegrationTests/TimersTest.js index c7eefb915333c3..8550c6f00eec6b 100644 --- a/IntegrationTests/TimersTest.js +++ b/IntegrationTests/TimersTest.js @@ -33,7 +33,7 @@ class TimersTest extends React.Component { _immediateIDs: Set = new Set(); _animationFrameIDs: Set = new Set(); - state = { + state: State = { count: 0, done: false, }; @@ -228,7 +228,7 @@ class TimersTest extends React.Component { } } - render() { + render(): React.Node { return ( diff --git a/IntegrationTests/WebSocketTest.js b/IntegrationTests/WebSocketTest.js index 0d2cd5e0b4d9e7..fcc2d74cb8d35c 100644 --- a/IntegrationTests/WebSocketTest.js +++ b/IntegrationTests/WebSocketTest.js @@ -113,7 +113,7 @@ class WebSocketTest extends React.Component<{}, State> { this.testConnect(); } - testConnect = () => { + testConnect: () => void = () => { this._connect(); this._waitFor(this._socketIsConnected, 5, connectSucceeded => { if (!connectSucceeded) { @@ -124,7 +124,7 @@ class WebSocketTest extends React.Component<{}, State> { }); }; - testSendAndReceive = () => { + testSendAndReceive: () => void = () => { this._sendTestMessage(); this._waitFor(this._receivedTestExpectedResponse, 5, messageReceived => { if (!messageReceived) { @@ -135,7 +135,7 @@ class WebSocketTest extends React.Component<{}, State> { }); }; - testDisconnect = () => { + testDisconnect: () => void = () => { this._disconnect(); this._waitFor(this._socketIsDisconnected, 5, disconnectSucceeded => { TestModule.markTestPassed(disconnectSucceeded); diff --git a/Libraries/ActionSheetIOS/NativeActionSheetManager.js b/Libraries/ActionSheetIOS/NativeActionSheetManager.js index 5f2a1ad0682c4c..28d5d080e82c50 100644 --- a/Libraries/ActionSheetIOS/NativeActionSheetManager.js +++ b/Libraries/ActionSheetIOS/NativeActionSheetManager.js @@ -47,4 +47,4 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.get('ActionSheetManager'); +export default (TurboModuleRegistry.get('ActionSheetManager'): ?Spec); diff --git a/Libraries/Alert/NativeAlertManager.js b/Libraries/Alert/NativeAlertManager.js index 1dcae0d265bd17..345fd08c6e65a2 100644 --- a/Libraries/Alert/NativeAlertManager.js +++ b/Libraries/Alert/NativeAlertManager.js @@ -31,4 +31,4 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.get('AlertManager'); +export default (TurboModuleRegistry.get('AlertManager'): ?Spec); diff --git a/Libraries/Animated/src/AnimatedEvent.js b/Libraries/Animated/src/AnimatedEvent.js index e06918ce5262e9..8e8c9c24068ce9 100644 --- a/Libraries/Animated/src/AnimatedEvent.js +++ b/Libraries/Animated/src/AnimatedEvent.js @@ -14,6 +14,7 @@ const NativeAnimatedHelper = require('./NativeAnimatedHelper'); const ReactNative = require('../../Renderer/shims/ReactNative'); const invariant = require('invariant'); + const {shouldUseNativeDriver} = require('./NativeAnimatedHelper'); export type Mapping = {[key: string]: Mapping} | AnimatedValue; @@ -26,7 +27,7 @@ function attachNativeEvent( viewRef: any, eventName: string, argMapping: Array, -) { +): $TEMPORARY$object<{|detach: () => void|}> { // Find animated values in `argMapping` and create an array representing their // key path inside the `nativeEvent` object. Ex.: ['contentOffset', 'x']. const eventMappings = []; @@ -130,7 +131,7 @@ class AnimatedEvent { this._attachedEvent && this._attachedEvent.detach(); } - __getHandler() { + __getHandler(): any | ((...args: any) => void) { if (this.__isNative) { return this._callListeners; } diff --git a/Libraries/Animated/src/AnimatedWeb.js b/Libraries/Animated/src/AnimatedWeb.js index 995db03f67b2b6..648c8a0bcccf64 100644 --- a/Libraries/Animated/src/AnimatedWeb.js +++ b/Libraries/Animated/src/AnimatedWeb.js @@ -14,7 +14,7 @@ const AnimatedImplementation = require('./AnimatedImplementation'); module.exports = { ...AnimatedImplementation, - div: AnimatedImplementation.createAnimatedComponent('div'), - span: AnimatedImplementation.createAnimatedComponent('span'), - img: AnimatedImplementation.createAnimatedComponent('img'), + div: (AnimatedImplementation.createAnimatedComponent('div'): $FlowFixMe), + span: (AnimatedImplementation.createAnimatedComponent('span'): $FlowFixMe), + img: (AnimatedImplementation.createAnimatedComponent('img'): $FlowFixMe), }; diff --git a/Libraries/Animated/src/Easing.js b/Libraries/Animated/src/Easing.js index 423c250fab4935..253a3e785aaa8a 100644 --- a/Libraries/Animated/src/Easing.js +++ b/Libraries/Animated/src/Easing.js @@ -61,14 +61,14 @@ class Easing { /** * A stepping function, returns 1 for any positive value of `n`. */ - static step0(n: number) { + static step0(n: number): number { return n > 0 ? 1 : 0; } /** * A stepping function, returns 1 if `n` is greater than or equal to 1. */ - static step1(n: number) { + static step1(n: number): number { return n >= 1 ? 1 : 0; } @@ -78,7 +78,7 @@ class Easing { * * http://cubic-bezier.com/#0,0,1,1 */ - static linear(t: number) { + static linear(t: number): number { return t; } @@ -101,7 +101,7 @@ class Easing { * * http://easings.net/#easeInQuad */ - static quad(t: number) { + static quad(t: number): number { return t * t; } @@ -111,7 +111,7 @@ class Easing { * * http://easings.net/#easeInCubic */ - static cubic(t: number) { + static cubic(t: number): number { return t * t * t; } @@ -121,7 +121,7 @@ class Easing { * n = 4: http://easings.net/#easeInQuart * n = 5: http://easings.net/#easeInQuint */ - static poly(n: number) { + static poly(n: number): (t: number) => number { return (t: number) => Math.pow(t, n); } @@ -130,7 +130,7 @@ class Easing { * * http://easings.net/#easeInSine */ - static sin(t: number) { + static sin(t: number): number { return 1 - Math.cos((t * Math.PI) / 2); } @@ -139,7 +139,7 @@ class Easing { * * http://easings.net/#easeInCirc */ - static circle(t: number) { + static circle(t: number): number { return 1 - Math.sqrt(1 - t * t); } @@ -148,7 +148,7 @@ class Easing { * * http://easings.net/#easeInExpo */ - static exp(t: number) { + static exp(t: number): number { return Math.pow(2, 10 * (t - 1)); } diff --git a/Libraries/Animated/src/NativeAnimatedHelper.js b/Libraries/Animated/src/NativeAnimatedHelper.js index 4a32be5492dc33..238a8fd2ba9d71 100644 --- a/Libraries/Animated/src/NativeAnimatedHelper.js +++ b/Libraries/Animated/src/NativeAnimatedHelper.js @@ -10,17 +10,16 @@ 'use strict'; import NativeEventEmitter from '../../EventEmitter/NativeEventEmitter'; +import type {EventConfig} from './AnimatedEvent'; +import NativeAnimatedModule from './NativeAnimatedModule'; import type { EventMapping, AnimatedNodeConfig, AnimatingNodeConfig, } from './NativeAnimatedModule'; -import NativeAnimatedModule from './NativeAnimatedModule'; -import invariant from 'invariant'; - import type {AnimationConfig, EndCallback} from './animations/Animation'; import type {InterpolationConfigType} from './nodes/AnimatedInterpolation'; -import type {EventConfig} from './AnimatedEvent'; +import invariant from 'invariant'; let __nativeAnimatedNodeTagCount = 1; /* used for animated nodes */ let __nativeAnimationIdCount = 1; /* used for started animations */ @@ -312,7 +311,7 @@ module.exports = { shouldUseNativeDriver, transformDataType, // $FlowExpectedError - unsafe getter lint suppresion - get nativeEventEmitter() { + get nativeEventEmitter(): NativeEventEmitter { if (!nativeEventEmitter) { nativeEventEmitter = new NativeEventEmitter(NativeAnimatedModule); } diff --git a/Libraries/Animated/src/NativeAnimatedModule.js b/Libraries/Animated/src/NativeAnimatedModule.js index 80ece9d69d04cf..7fcdfc4d871361 100644 --- a/Libraries/Animated/src/NativeAnimatedModule.js +++ b/Libraries/Animated/src/NativeAnimatedModule.js @@ -67,4 +67,4 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.get('NativeAnimatedModule'); +export default (TurboModuleRegistry.get('NativeAnimatedModule'): ?Spec); diff --git a/Libraries/Animated/src/animations/DecayAnimation.js b/Libraries/Animated/src/animations/DecayAnimation.js index a79f9c3ed42912..27ec5d8dd51c54 100644 --- a/Libraries/Animated/src/animations/DecayAnimation.js +++ b/Libraries/Animated/src/animations/DecayAnimation.js @@ -13,8 +13,8 @@ const Animation = require('./Animation'); const {shouldUseNativeDriver} = require('../NativeAnimatedHelper'); -import type {AnimationConfig, EndCallback} from './Animation'; import type AnimatedValue from '../nodes/AnimatedValue'; +import type {AnimationConfig, EndCallback} from './Animation'; export type DecayAnimationConfig = AnimationConfig & { velocity: number | {x: number, y: number}, @@ -45,7 +45,12 @@ class DecayAnimation extends Animation { this.__iterations = config.iterations ?? 1; } - __getNativeAnimationConfig() { + __getNativeAnimationConfig(): $TEMPORARY$object<{| + deceleration: number, + iterations: number, + type: $TEMPORARY$string<'decay'>, + velocity: number, + |}> { return { type: 'decay', deceleration: this._deceleration, diff --git a/Libraries/Animated/src/animations/SpringAnimation.js b/Libraries/Animated/src/animations/SpringAnimation.js index a7ffac480ac688..9a16bde6b71c5e 100644 --- a/Libraries/Animated/src/animations/SpringAnimation.js +++ b/Libraries/Animated/src/animations/SpringAnimation.js @@ -15,6 +15,7 @@ const Animation = require('./Animation'); const SpringConfig = require('../SpringConfig'); const invariant = require('invariant'); + const {shouldUseNativeDriver} = require('../NativeAnimatedHelper'); import type {AnimationConfig, EndCallback} from './Animation'; @@ -137,7 +138,18 @@ class SpringAnimation extends Animation { invariant(this._mass > 0, 'Mass value must be greater than 0'); } - __getNativeAnimationConfig() { + __getNativeAnimationConfig(): $TEMPORARY$object<{| + damping: number, + initialVelocity: number, + iterations: number, + mass: number, + overshootClamping: boolean, + restDisplacementThreshold: number, + restSpeedThreshold: number, + stiffness: number, + toValue: any, + type: $TEMPORARY$string<'spring'>, + |}> { return { type: 'spring', overshootClamping: this._overshootClamping, diff --git a/Libraries/Animated/src/bezier.js b/Libraries/Animated/src/bezier.js index 727872b848aacd..94fe109d784677 100644 --- a/Libraries/Animated/src/bezier.js +++ b/Libraries/Animated/src/bezier.js @@ -84,7 +84,7 @@ module.exports = function bezier( mY1: number, mX2: number, mY2: number, -) { +): (x: number) => number { if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) { throw new Error('bezier x values must be in [0, 1] range'); } diff --git a/Libraries/Animated/src/components/AnimatedFlatList.js b/Libraries/Animated/src/components/AnimatedFlatList.js index 9e91e84d9a18d1..2cc3704df4f2e0 100644 --- a/Libraries/Animated/src/components/AnimatedFlatList.js +++ b/Libraries/Animated/src/components/AnimatedFlatList.js @@ -14,6 +14,6 @@ const FlatList = require('../../../Lists/FlatList'); const createAnimatedComponent = require('../createAnimatedComponent'); -module.exports = createAnimatedComponent(FlatList, { +module.exports = (createAnimatedComponent(FlatList, { scrollEventThrottle: 0.0001, -}); +}): $FlowFixMe); diff --git a/Libraries/Animated/src/components/AnimatedImage.js b/Libraries/Animated/src/components/AnimatedImage.js index 9f5bad944b6eb1..89fee4d29ea8da 100644 --- a/Libraries/Animated/src/components/AnimatedImage.js +++ b/Libraries/Animated/src/components/AnimatedImage.js @@ -14,4 +14,4 @@ const Image = require('../../../Image/Image'); const createAnimatedComponent = require('../createAnimatedComponent'); -module.exports = createAnimatedComponent(Image); +module.exports = (createAnimatedComponent(Image): $FlowFixMe); diff --git a/Libraries/Animated/src/components/AnimatedScrollView.js b/Libraries/Animated/src/components/AnimatedScrollView.js index 16169dcefe8b2f..5913fb939a159a 100644 --- a/Libraries/Animated/src/components/AnimatedScrollView.js +++ b/Libraries/Animated/src/components/AnimatedScrollView.js @@ -14,6 +14,6 @@ const ScrollView = require('../../../Components/ScrollView/ScrollView'); const createAnimatedComponent = require('../createAnimatedComponent'); -module.exports = createAnimatedComponent(ScrollView, { +module.exports = (createAnimatedComponent(ScrollView, { scrollEventThrottle: 0.0001, -}); +}): $FlowFixMe); diff --git a/Libraries/Animated/src/components/AnimatedSectionList.js b/Libraries/Animated/src/components/AnimatedSectionList.js index 115e48d443cc3f..6a4a6389fbf668 100644 --- a/Libraries/Animated/src/components/AnimatedSectionList.js +++ b/Libraries/Animated/src/components/AnimatedSectionList.js @@ -14,6 +14,6 @@ const SectionList = require('../../../Lists/SectionList'); const createAnimatedComponent = require('../createAnimatedComponent'); -module.exports = createAnimatedComponent(SectionList, { +module.exports = (createAnimatedComponent(SectionList, { scrollEventThrottle: 0.0001, -}); +}): $FlowFixMe); diff --git a/Libraries/Animated/src/components/AnimatedText.js b/Libraries/Animated/src/components/AnimatedText.js index 73f9f5e3d68b66..81b016cca18d41 100644 --- a/Libraries/Animated/src/components/AnimatedText.js +++ b/Libraries/Animated/src/components/AnimatedText.js @@ -14,4 +14,4 @@ const Text = require('../../../Text/Text'); const createAnimatedComponent = require('../createAnimatedComponent'); -module.exports = createAnimatedComponent(Text); +module.exports = (createAnimatedComponent(Text): $FlowFixMe); diff --git a/Libraries/Animated/src/components/AnimatedView.js b/Libraries/Animated/src/components/AnimatedView.js index 6958289d509187..7684dbf3f50da7 100644 --- a/Libraries/Animated/src/components/AnimatedView.js +++ b/Libraries/Animated/src/components/AnimatedView.js @@ -14,4 +14,4 @@ const View = require('../../../Components/View/View'); const createAnimatedComponent = require('../createAnimatedComponent'); -module.exports = createAnimatedComponent(View); +module.exports = (createAnimatedComponent(View): $FlowFixMe); diff --git a/Libraries/AppState/NativeAppState.js b/Libraries/AppState/NativeAppState.js index ffea188b92bcd0..1146bf588dbbb6 100644 --- a/Libraries/AppState/NativeAppState.js +++ b/Libraries/AppState/NativeAppState.js @@ -27,4 +27,4 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.getEnforcing('AppState'); +export default (TurboModuleRegistry.getEnforcing('AppState'): Spec); diff --git a/Libraries/BatchedBridge/BatchedBridge.js b/Libraries/BatchedBridge/BatchedBridge.js index 5cd0138b48e131..b68e9873e393ba 100644 --- a/Libraries/BatchedBridge/BatchedBridge.js +++ b/Libraries/BatchedBridge/BatchedBridge.js @@ -12,7 +12,7 @@ const MessageQueue = require('./MessageQueue'); -const BatchedBridge = new MessageQueue(); +const BatchedBridge: MessageQueue = new MessageQueue(); // Wire up the batched bridge on the global object so that we can call into it. // Ideally, this would be the inverse relationship. I.e. the native environment diff --git a/Libraries/BatchedBridge/MessageQueue.js b/Libraries/BatchedBridge/MessageQueue.js index b12295e840cf30..260a38f297dd15 100644 --- a/Libraries/BatchedBridge/MessageQueue.js +++ b/Libraries/BatchedBridge/MessageQueue.js @@ -101,7 +101,11 @@ class MessageQueue { } } - callFunctionReturnFlushedQueue(module: string, method: string, args: any[]) { + callFunctionReturnFlushedQueue( + module: string, + method: string, + args: any[], + ): null | [Array, Array, Array, number] { this.__guard(() => { this.__callFunction(module, method, args); }); @@ -113,7 +117,7 @@ class MessageQueue { module: string, method: string, args: any[], - ) { + ): $TEMPORARY$array, Array, Array, number]> { let result; this.__guard(() => { result = this.__callFunction(module, method, args); @@ -122,7 +126,10 @@ class MessageQueue { return [result, this.flushedQueue()]; } - invokeCallbackAndReturnFlushedQueue(cbID: number, args: any[]) { + invokeCallbackAndReturnFlushedQueue( + cbID: number, + args: any[], + ): null | [Array, Array, Array, number] { this.__guard(() => { this.__invokeCallback(cbID, args); }); @@ -130,7 +137,7 @@ class MessageQueue { return this.flushedQueue(); } - flushedQueue() { + flushedQueue(): null | [Array, Array, Array, number] { this.__guard(() => { this.__callImmediates(); }); @@ -140,7 +147,7 @@ class MessageQueue { return queue[0].length ? queue : null; } - getEventLoopRunningTime() { + getEventLoopRunningTime(): number { return Date.now() - this._eventLoopStartTime; } @@ -160,7 +167,7 @@ class MessageQueue { }; } - getCallableModule(name: string) { + getCallableModule(name: string): any | null { const getValue = this._lazyCallableModules[name]; return getValue ? getValue() : null; } @@ -171,7 +178,7 @@ class MessageQueue { params: any[], onFail: ?Function, onSucc: ?Function, - ) { + ): any { if (__DEV__) { invariant( global.nativeCallSyncHook, @@ -383,7 +390,7 @@ class MessageQueue { // This makes stacktraces to be placed at MessageQueue rather than at where they were launched // The parameter DebuggerInternal.shouldPauseOnThrow is used to check before catching all exceptions and // can be configured by the VM or any Inspector - __shouldPauseOnThrow() { + __shouldPauseOnThrow(): boolean { return ( // $FlowFixMe typeof DebuggerInternal !== 'undefined' && diff --git a/Libraries/Blob/BlobManager.js b/Libraries/Blob/BlobManager.js index 9176218373ca67..e12512392a3e78 100644 --- a/Libraries/Blob/BlobManager.js +++ b/Libraries/Blob/BlobManager.js @@ -12,10 +12,10 @@ const Blob = require('./Blob'); const BlobRegistry = require('./BlobRegistry'); -import NativeBlobModule from './NativeBlobModule'; -import invariant from 'invariant'; import type {BlobData, BlobOptions, BlobCollector} from './BlobTypes'; +import NativeBlobModule from './NativeBlobModule'; +import invariant from 'invariant'; /*eslint-disable no-bitwise */ /*eslint-disable eqeqeq */ @@ -54,7 +54,7 @@ class BlobManager { /** * If the native blob module is available. */ - static isAvailable = !!NativeBlobModule; + static isAvailable: boolean = !!NativeBlobModule; /** * Create blob from existing array of blobs. diff --git a/Libraries/Blob/BlobRegistry.js b/Libraries/Blob/BlobRegistry.js index cfd0475a53ea07..f3cd13ebc48fbb 100644 --- a/Libraries/Blob/BlobRegistry.js +++ b/Libraries/Blob/BlobRegistry.js @@ -27,7 +27,7 @@ const unregister = (id: string) => { } }; -const has = (id: string) => { +const has = (id: string): number | boolean => { return registry[id] && registry[id] > 0; }; diff --git a/Libraries/Blob/FileReader.js b/Libraries/Blob/FileReader.js index b9113966f1a9fb..fc769f8a544a72 100644 --- a/Libraries/Blob/FileReader.js +++ b/Libraries/Blob/FileReader.js @@ -10,8 +10,9 @@ 'use strict'; -const EventTarget = require('event-target-shim'); const Blob = require('./Blob'); +const EventTarget = require('event-target-shim'); + import NativeFileReaderModule from './NativeFileReaderModule'; type ReadyState = @@ -34,14 +35,14 @@ const EMPTY = 0; const LOADING = 1; const DONE = 2; -class FileReader extends EventTarget(...READER_EVENTS) { - static EMPTY = EMPTY; - static LOADING = LOADING; - static DONE = DONE; +class FileReader extends (EventTarget(...READER_EVENTS): any) { + static EMPTY: number = EMPTY; + static LOADING: number = LOADING; + static DONE: number = DONE; - EMPTY = EMPTY; - LOADING = LOADING; - DONE = DONE; + EMPTY: number = EMPTY; + LOADING: number = LOADING; + DONE: number = DONE; _readyState: ReadyState; _error: ?Error; diff --git a/Libraries/Blob/NativeBlobModule.js b/Libraries/Blob/NativeBlobModule.js index cb44600c642ae6..2949b755951b5a 100644 --- a/Libraries/Blob/NativeBlobModule.js +++ b/Libraries/Blob/NativeBlobModule.js @@ -23,4 +23,4 @@ export interface Spec extends TurboModule { +release: (blobId: string) => void; } -export default TurboModuleRegistry.get('BlobModule'); +export default (TurboModuleRegistry.get('BlobModule'): ?Spec); diff --git a/Libraries/Blob/NativeFileReaderModule.js b/Libraries/Blob/NativeFileReaderModule.js index 2291c2e60ad21f..ac135db7394d19 100644 --- a/Libraries/Blob/NativeFileReaderModule.js +++ b/Libraries/Blob/NativeFileReaderModule.js @@ -18,4 +18,6 @@ export interface Spec extends TurboModule { +readAsText: (data: Object, encoding: string) => Promise; } -export default TurboModuleRegistry.getEnforcing('FileReaderModule'); +export default (TurboModuleRegistry.getEnforcing( + 'FileReaderModule', +): Spec); diff --git a/Libraries/Blob/__mocks__/FileReaderModule.js b/Libraries/Blob/__mocks__/FileReaderModule.js index da687eca470b1d..a3cdbf6848cd1a 100644 --- a/Libraries/Blob/__mocks__/FileReaderModule.js +++ b/Libraries/Blob/__mocks__/FileReaderModule.js @@ -8,10 +8,10 @@ * @format */ const FileReaderModule = { - async readAsText() { + async readAsText(): Promise { return ''; }, - async readAsDataURL() { + async readAsDataURL(): Promise { return 'data:text/plain;base64,NDI='; }, }; diff --git a/Libraries/BugReporting/dumpReactTree.js b/Libraries/BugReporting/dumpReactTree.js index 2ef17ecf034784..0960662911cc3a 100644 --- a/Libraries/BugReporting/dumpReactTree.js +++ b/Libraries/BugReporting/dumpReactTree.js @@ -23,7 +23,7 @@ const MAX_STRING_LENGTH = 50; * it best to get the content but ultimately relies on implementation details * of React and will fail in future versions. */ -function dumpReactTree() { +function dumpReactTree(): string { try { return getReactTree(); } catch (e) { diff --git a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js index a804af6fd68dd0..9a86653d452849 100644 --- a/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js +++ b/Libraries/Components/AccessibilityInfo/AccessibilityInfo.ios.js @@ -10,11 +10,11 @@ 'use strict'; -import NativeAccessibilityManager from './NativeAccessibilityManager'; - const Promise = require('../../Promise'); const RCTDeviceEventEmitter = require('../../EventEmitter/RCTDeviceEventEmitter'); +import NativeAccessibilityManager from './NativeAccessibilityManager'; + const CHANGE_EVENT_NAME = { announcementFinished: 'announcementFinished', boldTextChanged: 'boldTextChanged', @@ -164,7 +164,7 @@ const AccessibilityInfo = { * * Same as `isScreenReaderEnabled` */ - get fetch() { + get fetch(): $FlowFixMe { return this.isScreenReaderEnabled; }, diff --git a/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js b/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js index 2f51c3c183de30..ef2b968652082c 100644 --- a/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js +++ b/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js @@ -24,4 +24,4 @@ export interface Spec extends TurboModule { +announceForAccessibility: (announcement: string) => void; } -export default TurboModuleRegistry.get('AccessibilityInfo'); +export default (TurboModuleRegistry.get('AccessibilityInfo'): ?Spec); diff --git a/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js b/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js index b0fe8dd1d7ed70..8122934edcd4af 100644 --- a/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js +++ b/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager.js @@ -42,4 +42,4 @@ export interface Spec extends TurboModule { +announceForAccessibility: (announcement: string) => void; } -export default TurboModuleRegistry.get('AccessibilityManager'); +export default (TurboModuleRegistry.get('AccessibilityManager'): ?Spec); diff --git a/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js b/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js index 27f33bd7270df2..97edfcdf99c5d3 100644 --- a/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js +++ b/Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js @@ -18,4 +18,6 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.get('TVNavigationEventEmitter'); +export default (TurboModuleRegistry.get( + 'TVNavigationEventEmitter', +): ?Spec); diff --git a/Libraries/Components/Clipboard/NativeClipboard.js b/Libraries/Components/Clipboard/NativeClipboard.js index 002a7ebb2e9f8e..93fc92873eecda 100644 --- a/Libraries/Components/Clipboard/NativeClipboard.js +++ b/Libraries/Components/Clipboard/NativeClipboard.js @@ -19,4 +19,4 @@ export interface Spec extends TurboModule { +setString: (content: string) => void; } -export default TurboModuleRegistry.getEnforcing('Clipboard'); +export default (TurboModuleRegistry.getEnforcing('Clipboard'): Spec); diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index 9550619e9eb096..c01a3c495dd664 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -13,16 +13,15 @@ 'use strict'; +const RCTDatePickerNativeComponent = require('./RCTDatePickerNativeComponent'); const React = require('react'); const StyleSheet = require('../../StyleSheet/StyleSheet'); const View = require('../View/View'); const invariant = require('invariant'); -import type {ViewProps} from '../View/ViewPropTypes'; import type {SyntheticEvent} from '../../Types/CoreEventTypes'; - -const RCTDatePickerNativeComponent = require('./RCTDatePickerNativeComponent'); +import type {ViewProps} from '../View/ViewPropTypes'; type Event = SyntheticEvent< $ReadOnly<{| @@ -113,7 +112,9 @@ type Props = $ReadOnly<{| * source of truth. */ class DatePickerIOS extends React.Component { - static DefaultProps = { + static DefaultProps: $TEMPORARY$object<{| + mode: $TEMPORARY$string<'datetime'>, + |}> = { mode: 'datetime', }; @@ -137,7 +138,7 @@ class DatePickerIOS extends React.Component { this.props.onChange && this.props.onChange(event); }; - render() { + render(): React.Node { const props = this.props; invariant( props.date || props.initialDate, diff --git a/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js b/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js index a0676f033291b5..778befa4ebc84a 100644 --- a/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js +++ b/Libraries/Components/DatePickerAndroid/NativeDatePickerAndroid.js @@ -17,4 +17,6 @@ export interface Spec extends TurboModule { +open: (options: Object) => Promise; } -export default TurboModuleRegistry.getEnforcing('DatePickerAndroid'); +export default (TurboModuleRegistry.getEnforcing( + 'DatePickerAndroid', +): Spec); diff --git a/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js b/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js index 9507b691b58645..778b609fc29103 100644 --- a/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js +++ b/Libraries/Components/DrawerAndroid/AndroidDrawerLayoutNativeComponent.js @@ -10,17 +10,17 @@ 'use strict'; -import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands'; -import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; -import * as React from 'react'; import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; +import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; import type { WithDefault, DirectEventHandler, Int32, Float, } from 'react-native/Libraries/Types/CodegenTypes'; -import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; +import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands'; +import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'; +import * as React from 'react'; type DrawerStateEvent = $ReadOnly<{| drawerState: Int32, @@ -113,7 +113,7 @@ type NativeProps = $ReadOnly<{| statusBarBackgroundColor?: ?ColorValue, |}>; -export const Commands = codegenNativeCommands({ +export const Commands: NativeCommands = codegenNativeCommands({ supportedCommands: ['openDrawer', 'closeDrawer'], }); diff --git a/Libraries/Components/Keyboard/Keyboard.js b/Libraries/Components/Keyboard/Keyboard.js index 976aab0aa7daaf..a024a447861bcd 100644 --- a/Libraries/Components/Keyboard/Keyboard.js +++ b/Libraries/Components/Keyboard/Keyboard.js @@ -11,9 +11,10 @@ 'use strict'; const LayoutAnimation = require('../../LayoutAnimation/LayoutAnimation'); -const invariant = require('invariant'); const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter'); + const dismissKeyboard = require('../../Utilities/dismissKeyboard'); +const invariant = require('invariant'); import NativeKeyboardObserver from './NativeKeyboardObserver'; const KeyboardEventEmitter = new NativeEventEmitter(NativeKeyboardObserver); @@ -108,7 +109,21 @@ type KeyboardEventListener = (e: KeyboardEvent) => void; *``` */ -let Keyboard = { +let Keyboard: + | NativeEventEmitter + | $TEMPORARY$object<{| + addListener: ( + eventName: KeyboardEventName, + callback: KeyboardEventListener, + ) => $FlowFixMe, + dismiss: () => $FlowFixMe, + removeAllListeners: (eventName: KeyboardEventName) => $FlowFixMe, + removeListener: ( + eventName: KeyboardEventName, + callback: KeyboardEventListener, + ) => $FlowFixMe, + scheduleLayoutAnimation: (event: KeyboardEvent) => $FlowFixMe, + |}> = { /** * The `addListener` function connects a JavaScript function to an identified native * keyboard notification event. diff --git a/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 9f9bbbfc608185..ae0dd37fb0814c 100644 --- a/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -17,8 +17,8 @@ const React = require('react'); const StyleSheet = require('../../StyleSheet/StyleSheet'); const View = require('../View/View'); -import type EmitterSubscription from '../../vendor/emitter/EmitterSubscription'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; +import type EmitterSubscription from '../../vendor/emitter/EmitterSubscription'; import type { ViewProps, ViewLayout, @@ -61,7 +61,10 @@ type State = {| * adjusting its height, position, or bottom padding. */ class KeyboardAvoidingView extends React.Component { - static defaultProps = { + static defaultProps: $TEMPORARY$object<{| + enabled: boolean, + keyboardVerticalOffset: number, + |}> = { enabled: true, keyboardVerticalOffset: 0, }; diff --git a/Libraries/Components/Keyboard/NativeKeyboardObserver.js b/Libraries/Components/Keyboard/NativeKeyboardObserver.js index 04d95a6b69b292..e26598dd4cec3e 100644 --- a/Libraries/Components/Keyboard/NativeKeyboardObserver.js +++ b/Libraries/Components/Keyboard/NativeKeyboardObserver.js @@ -18,4 +18,4 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.get('KeyboardObserver'); +export default (TurboModuleRegistry.get('KeyboardObserver'): ?Spec); diff --git a/Libraries/Components/MaskedView/MaskedViewIOS.ios.js b/Libraries/Components/MaskedView/MaskedViewIOS.ios.js index 7caff48178c768..4a32d29836f8d0 100644 --- a/Libraries/Components/MaskedView/MaskedViewIOS.ios.js +++ b/Libraries/Components/MaskedView/MaskedViewIOS.ios.js @@ -11,9 +11,9 @@ const React = require('react'); const StyleSheet = require('../../StyleSheet/StyleSheet'); const View = require('../View/View'); -import RCTMaskedViewNativeComponent from './RCTMaskedViewNativeComponent'; import type {ViewProps} from '../View/ViewPropTypes'; +import RCTMaskedViewNativeComponent from './RCTMaskedViewNativeComponent'; type Props = $ReadOnly<{| ...ViewProps, @@ -65,7 +65,7 @@ type Props = $ReadOnly<{| class MaskedViewIOS extends React.Component { _hasWarnedInvalidRenderMask = false; - render() { + render(): React.Node { const {maskElement, children, ...otherViewProps} = this.props; if (!React.isValidElement(maskElement)) { diff --git a/Libraries/Components/Picker/Picker.js b/Libraries/Components/Picker/Picker.js index 5353986959f686..cded08c74d8d15 100644 --- a/Libraries/Components/Picker/Picker.js +++ b/Libraries/Components/Picker/Picker.js @@ -121,20 +121,22 @@ class Picker extends React.Component { /** * On Android, display the options in a dialog. */ - static MODE_DIALOG = MODE_DIALOG; + static MODE_DIALOG: $TEMPORARY$string<'dialog'> = MODE_DIALOG; /** * On Android, display the options in a dropdown (this is the default). */ - static MODE_DROPDOWN = MODE_DROPDOWN; + static MODE_DROPDOWN: $TEMPORARY$string<'dropdown'> = MODE_DROPDOWN; - static Item = PickerItem; + static Item: typeof PickerItem = PickerItem; - static defaultProps = { + static defaultProps: $TEMPORARY$object<{| + mode: $TEMPORARY$string<'dialog'>, + |}> = { mode: MODE_DIALOG, }; - render() { + render(): React.Node { if (Platform.OS === 'ios') { /* $FlowFixMe(>=0.81.0 site=react_native_ios_fb) This suppression was * added when renaming suppression sites. */ diff --git a/Libraries/Components/Picker/PickerIOS.ios.js b/Libraries/Components/Picker/PickerIOS.ios.js index 382b6df6153982..7a642f97120d1d 100644 --- a/Libraries/Components/Picker/PickerIOS.ios.js +++ b/Libraries/Components/Picker/PickerIOS.ios.js @@ -13,17 +13,18 @@ 'use strict'; +const RCTPickerNativeComponent = require('./RCTPickerNativeComponent'); const React = require('react'); const ReactNative = require('../../Renderer/shims/ReactNative'); const StyleSheet = require('../../StyleSheet/StyleSheet'); const View = require('../View/View'); + const processColor = require('../../StyleSheet/processColor'); -const RCTPickerNativeComponent = require('./RCTPickerNativeComponent'); -import type {SyntheticEvent} from '../../Types/CoreEventTypes'; +import type {TextStyleProp} from '../../StyleSheet/StyleSheet'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; +import type {SyntheticEvent} from '../../Types/CoreEventTypes'; import type {ViewProps} from '../View/ViewPropTypes'; -import type {TextStyleProp} from '../../StyleSheet/StyleSheet'; type PickerIOSChangeEvent = SyntheticEvent< $ReadOnly<{| @@ -74,19 +75,19 @@ type ItemProps = $ReadOnly<{| color?: ?ColorValue, |}>; -const PickerIOSItem = (props: ItemProps) => { +const PickerIOSItem = (props: ItemProps): null => { return null; }; class PickerIOS extends React.Component { _picker: ?React.ElementRef = null; - state = { + state: State = { selectedIndex: 0, items: [], }; - static Item = PickerIOSItem; + static Item: (props: ItemProps) => null = PickerIOSItem; static getDerivedStateFromProps(props: Props): State { let selectedIndex = 0; @@ -106,7 +107,7 @@ class PickerIOS extends React.Component { return {selectedIndex, items}; } - render() { + render(): React.Node { return ( { componentDidMount() { RefreshControlMock.latestRef = this; } - render() { + render(): React.Element { return ; } } diff --git a/Libraries/Components/SafeAreaView/SafeAreaView.js b/Libraries/Components/SafeAreaView/SafeAreaView.js index 61be02b030ea1b..a6d7afc1b97492 100644 --- a/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -12,15 +12,15 @@ const Platform = require('../../Utilities/Platform'); const React = require('react'); const View = require('../View/View'); -import type {ViewProps} from '../View/ViewPropTypes'; import type {NativeComponent} from '../../Renderer/shims/ReactNative'; +import type {ViewProps} from '../View/ViewPropTypes'; type Props = $ReadOnly<{| ...ViewProps, emulateUnlessSupported?: boolean, |}>; -let exported; +let exported: Class> | Class>; /** * Renders nested content and automatically applies paddings reflect the portion diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index a16c4b49d23e58..b4298158b3354f 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -27,21 +27,20 @@ const requireNativeComponent = require('../../ReactNative/requireNativeComponent const resolveAssetSource = require('../../Image/resolveAssetSource'); const splitLayoutProps = require('../../StyleSheet/splitLayoutProps'); +import type {NativeMethodsMixinType} from '../../Renderer/shims/ReactNativeTypes'; +import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; +import type {PointProp} from '../../StyleSheet/PointPropType'; +import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; +import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type { PressEvent, ScrollEvent, LayoutEvent, } from '../../Types/CoreEventTypes'; -import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; -import type {NativeMethodsMixinType} from '../../Renderer/shims/ReactNativeTypes'; -import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; +import type {State as ScrollResponderState} from '../ScrollResponder'; import type {ViewProps} from '../View/ViewPropTypes'; -import type {PointProp} from '../../StyleSheet/PointPropType'; import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader'; -import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; -import type {State as ScrollResponderState} from '../ScrollResponder'; - let AndroidScrollView; let AndroidHorizontalScrollContentView; let AndroidHorizontalScrollView; @@ -628,7 +627,7 @@ const standardVerticalContext: ContextType = Object.freeze({horizontal: false}); * supports out of the box. */ class ScrollView extends React.Component { - static Context = Context; + static Context: React$Context = Context; /** * Part 1: Removing ScrollResponder.Mixin: * @@ -688,7 +687,7 @@ class ScrollView extends React.Component { _stickyHeaderRefs: Map = new Map(); _headerLayoutYs: Map = new Map(); - state = { + state: State = { layoutHeight: null, ...ScrollResponder.Mixin.scrollResponderMixinGetInitialState(), }; @@ -941,7 +940,7 @@ class ScrollView extends React.Component { this._innerViewRef = ref; }; - render() { + render(): React.Node | React.Element { let ScrollViewClass; let ScrollContentContainerViewClass; if (Platform.OS === 'android') { diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 702d23667f98b0..c9a967f9c85602 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -38,7 +38,7 @@ type State = { }; class ScrollViewStickyHeader extends React.Component { - state = { + state: State = { measured: false, layoutY: 0, layoutHeight: 0, @@ -63,7 +63,7 @@ class ScrollViewStickyHeader extends React.Component { } }; - render() { + render(): React.Node { const {inverted, scrollViewHeight} = this.props; const {measured, layoutHeight, layoutY, nextHeaderLayoutY} = this.state; const inputRange: Array = [-1, 0]; diff --git a/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js b/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js index 85195684ca7cca..7360b7778dcaff 100644 --- a/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js +++ b/Libraries/Components/ScrollView/__mocks__/ScrollViewMock.js @@ -19,10 +19,10 @@ const requireNativeComponent = require('../../../ReactNative/requireNativeCompon const RCTScrollView = requireNativeComponent('RCTScrollView'); -const ScrollViewComponent = jest.genMockFromModule('../ScrollView'); +const ScrollViewComponent: $FlowFixMe = jest.genMockFromModule('../ScrollView'); class ScrollViewMock extends ScrollViewComponent { - render() { + render(): React.Element { return ( {this.props.refreshControl} diff --git a/Libraries/Components/Sound/NativeSoundManager.js b/Libraries/Components/Sound/NativeSoundManager.js index 4858305cadef3b..80ba8743fde455 100644 --- a/Libraries/Components/Sound/NativeSoundManager.js +++ b/Libraries/Components/Sound/NativeSoundManager.js @@ -20,4 +20,4 @@ export interface Spec extends TurboModule { +playTouchSound: () => void; } -export default TurboModuleRegistry.getEnforcing('SoundManager'); +export default (TurboModuleRegistry.getEnforcing('SoundManager'): Spec); diff --git a/Libraries/Components/StaticContainer.react.js b/Libraries/Components/StaticContainer.react.js index 948e16ef85c5c0..aab461272d19ff 100644 --- a/Libraries/Components/StaticContainer.react.js +++ b/Libraries/Components/StaticContainer.react.js @@ -43,7 +43,7 @@ class StaticContainer extends React.Component { return !!nextProps.shouldUpdate; } - render() { + render(): null | React$Node { const child = this.props.children; return child === null || child === false ? null diff --git a/Libraries/Components/StatusBar/NativeStatusBarManager.js b/Libraries/Components/StatusBar/NativeStatusBarManager.js index 4c7337ad9d2f7f..9743d22275894f 100644 --- a/Libraries/Components/StatusBar/NativeStatusBarManager.js +++ b/Libraries/Components/StatusBar/NativeStatusBarManager.js @@ -45,4 +45,6 @@ export interface Spec extends TurboModule { +setHidden: (hidden: boolean, withAnimation?: ?string) => void; } -export default TurboModuleRegistry.getEnforcing('StatusBarManager'); +export default (TurboModuleRegistry.getEnforcing( + 'StatusBarManager', +): Spec); diff --git a/Libraries/Components/StatusBar/StatusBar.js b/Libraries/Components/StatusBar/StatusBar.js index cb4a8f74e88431..4d50ce488015b4 100644 --- a/Libraries/Components/StatusBar/StatusBar.js +++ b/Libraries/Components/StatusBar/StatusBar.js @@ -10,10 +10,11 @@ 'use strict'; -const React = require('react'); const Platform = require('../../Utilities/Platform'); +const React = require('react'); const processColor = require('../../StyleSheet/processColor'); + import NativeStatusBarManager from './NativeStatusBarManager'; /** @@ -245,7 +246,7 @@ class StatusBar extends React.Component { * * @platform android */ - static currentHeight = NativeStatusBarManager.getConstants().HEIGHT; + static currentHeight: number = NativeStatusBarManager.getConstants().HEIGHT; // Provide an imperative API as static functions of the component. // See the corresponding prop for more detail. @@ -339,7 +340,7 @@ class StatusBar extends React.Component { * * @param props Object containing the StatusBar props to use in the stack entry. */ - static pushStackEntry(props: any) { + static pushStackEntry(props: any): any { const entry = createStackEntry(props); StatusBar._propsStack.push(entry); StatusBar._updatePropsStack(); @@ -365,7 +366,7 @@ class StatusBar extends React.Component { * @param entry Entry returned from `pushStackEntry` to replace. * @param props Object containing the StatusBar props to use in the replacement stack entry. */ - static replaceStackEntry(entry: any, props: any) { + static replaceStackEntry(entry: any, props: any): any { const newEntry = createStackEntry(props); const index = StatusBar._propsStack.indexOf(entry); if (index !== -1) { @@ -375,7 +376,10 @@ class StatusBar extends React.Component { return newEntry; } - static defaultProps = { + static defaultProps: $TEMPORARY$object<{| + animated: boolean, + showHideTransition: $TEMPORARY$string<'fade'>, + |}> = { animated: false, showHideTransition: 'fade', }; diff --git a/Libraries/Components/StatusBar/StatusBarIOS.ios.js b/Libraries/Components/StatusBar/StatusBarIOS.ios.js index de852f8de4f058..f3ebbf4d98824c 100644 --- a/Libraries/Components/StatusBar/StatusBarIOS.ios.js +++ b/Libraries/Components/StatusBar/StatusBarIOS.ios.js @@ -11,6 +11,7 @@ 'use strict'; const NativeEventEmitter = require('../../EventEmitter/NativeEventEmitter'); + import NativeStatusBarManager from './NativeStatusBarManager'; /** @@ -18,4 +19,4 @@ import NativeStatusBarManager from './NativeStatusBarManager'; */ class StatusBarIOS extends NativeEventEmitter {} -module.exports = new StatusBarIOS(NativeStatusBarManager); +module.exports = (new StatusBarIOS(NativeStatusBarManager): StatusBarIOS); diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index 2a069baa1fb74c..3eb9f092f883d6 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -10,15 +10,15 @@ 'use strict'; -import SwitchNativeComponent from './SwitchNativeComponent'; const AndroidSwitchNativeComponent = require('./AndroidSwitchNativeComponent'); const Platform = require('../../Utilities/Platform'); const React = require('react'); const StyleSheet = require('../../StyleSheet/StyleSheet'); -import type {SyntheticEvent} from '../../Types/CoreEventTypes'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; +import type {SyntheticEvent} from '../../Types/CoreEventTypes'; import type {ViewProps} from '../View/ViewPropTypes'; +import SwitchNativeComponent from './SwitchNativeComponent'; type SwitchChangeEvent = SyntheticEvent< $ReadOnly<{| @@ -93,7 +93,7 @@ class Switch extends React.Component { typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent, >; - render() { + render(): React.Node { const { disabled, ios_backgroundColor, diff --git a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index aa6b88ea8a7a55..baf644cbb250a4 100644 --- a/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -12,7 +12,7 @@ import {requireNativeComponent} from 'react-native'; -const AndroidTextInputNativeComponent = requireNativeComponent( +const AndroidTextInputNativeComponent: string = requireNativeComponent( 'AndroidTextInput', ); diff --git a/Libraries/Components/TextInput/TextInputState.js b/Libraries/Components/TextInput/TextInputState.js index 5ce5595c461892..ec5b348db7b204 100644 --- a/Libraries/Components/TextInput/TextInputState.js +++ b/Libraries/Components/TextInput/TextInputState.js @@ -79,7 +79,7 @@ function unregisterInput(textFieldID: number) { inputs.delete(textFieldID); } -function isTextInput(textFieldID: number) { +function isTextInput(textFieldID: number): boolean { return inputs.has(textFieldID); } diff --git a/Libraries/Components/TimePickerAndroid/NativeTimePickerAndroid.js b/Libraries/Components/TimePickerAndroid/NativeTimePickerAndroid.js index a23de52629f100..ac4aa7e6eb3e18 100644 --- a/Libraries/Components/TimePickerAndroid/NativeTimePickerAndroid.js +++ b/Libraries/Components/TimePickerAndroid/NativeTimePickerAndroid.js @@ -30,4 +30,4 @@ export interface Spec extends TurboModule { +open: (options: TimePickerOptions) => Promise; } -export default TurboModuleRegistry.get('TimePickerAndroid'); +export default (TurboModuleRegistry.get('TimePickerAndroid'): ?Spec); diff --git a/Libraries/Components/ToastAndroid/NativeToastAndroid.js b/Libraries/Components/ToastAndroid/NativeToastAndroid.js index 079a7d0112bcfd..f61d11bbc034e5 100644 --- a/Libraries/Components/ToastAndroid/NativeToastAndroid.js +++ b/Libraries/Components/ToastAndroid/NativeToastAndroid.js @@ -36,4 +36,4 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.getEnforcing('ToastAndroid'); +export default (TurboModuleRegistry.getEnforcing('ToastAndroid'): Spec); diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 0170576855d5c0..a37a4fa24d4f78 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -23,8 +23,8 @@ const View = require('../View/View'); const keyMirror = require('fbjs/lib/keyMirror'); const normalizeColor = require('../../Color/normalizeColor'); -import type {PressEvent} from '../../Types/CoreEventTypes'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; +import type {PressEvent} from '../../Types/CoreEventTypes'; const extractSingleTouch = nativeEvent => { const touches = nativeEvent.touches; @@ -409,7 +409,9 @@ const TouchableMixin = { * @return {object} State object to be placed inside of * `this.state.touchable`. */ - touchableGetInitialState: function() { + touchableGetInitialState: function(): $TEMPORARY$object<{| + touchable: $TEMPORARY$object<{|responderID: null, touchState: void|}>, + |}> { return { touchable: {touchState: undefined, responderID: null}, }; @@ -419,21 +421,21 @@ const TouchableMixin = { /** * Must return true if embedded in a native platform scroll view. */ - touchableHandleResponderTerminationRequest: function() { + touchableHandleResponderTerminationRequest: function(): any { return !this.props.rejectResponderTermination; }, /** * Must return true to start the process of `Touchable`. */ - touchableHandleStartShouldSetResponder: function() { + touchableHandleStartShouldSetResponder: function(): any { return !this.props.disabled; }, /** * Return true to cancel press on long press. */ - touchableLongPressCancelsPress: function() { + touchableLongPressCancelsPress: function(): boolean { return true; }, @@ -784,7 +786,7 @@ const TouchableMixin = { this.longPressDelayTimeout = null; }, - _isHighlight: function(state: State) { + _isHighlight: function(state: State): boolean { return ( state === States.RESPONDER_ACTIVE_PRESS_IN || state === States.RESPONDER_ACTIVE_LONG_PRESS_IN @@ -805,7 +807,7 @@ const TouchableMixin = { aY: number, bX: number, bY: number, - ) { + ): number { const deltaX = aX - bX; const deltaY = aY - bY; return Math.sqrt(deltaX * deltaX + deltaY * deltaY); @@ -907,7 +909,7 @@ const TouchableMixin = { } }, - withoutDefaultFocusAndBlur: {}, + withoutDefaultFocusAndBlur: ({}: $TEMPORARY$object<{||}>), }; /** @@ -935,7 +937,7 @@ const Touchable = { }: { color: string | number, hitSlop: EdgeInsetsProp, - }) => { + }): null | React.Node => { if (!Touchable.TOUCH_TARGET_DEBUG) { return null; } diff --git a/Libraries/Components/UnimplementedViews/UnimplementedView.js b/Libraries/Components/UnimplementedViews/UnimplementedView.js index d507629710e16c..4d091bd660fe91 100644 --- a/Libraries/Components/UnimplementedViews/UnimplementedView.js +++ b/Libraries/Components/UnimplementedViews/UnimplementedView.js @@ -23,7 +23,7 @@ class UnimplementedView extends React.Component<$FlowFixMeProps> { // See ensureComponentIsNative.js for more info } - render() { + render(): React.Node { // Workaround require cycle from requireNativeComponent const View = require('../View/View'); return ( diff --git a/Libraries/Components/View/ReactNativeViewViewConfig.js b/Libraries/Components/View/ReactNativeViewViewConfig.js index 62b480c7f2d806..39a603a6eb7807 100644 --- a/Libraries/Components/View/ReactNativeViewViewConfig.js +++ b/Libraries/Components/View/ReactNativeViewViewConfig.js @@ -15,8 +15,8 @@ const ReactNativeViewConfig = { uiViewClassName: 'RCTView', baseModuleName: null, Manager: 'ViewManager', - Commands: {}, - Constants: {}, + Commands: ({}: $TEMPORARY$object<{||}>), + Constants: ({}: $TEMPORARY$object<{||}>), bubblingEventTypes: { ...ReactNativeViewViewConfigAndroid.bubblingEventTypes, topBlur: { diff --git a/Libraries/Components/View/ViewNativeComponent.js b/Libraries/Components/View/ViewNativeComponent.js index 6d8408f48f659e..f954a2d6c2f474 100644 --- a/Libraries/Components/View/ViewNativeComponent.js +++ b/Libraries/Components/View/ViewNativeComponent.js @@ -10,10 +10,11 @@ 'use strict'; -const ReactNative = require('../../Renderer/shims/ReactNative'); const Platform = require('../../Utilities/Platform'); -const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig'); +const ReactNative = require('../../Renderer/shims/ReactNative'); const ReactNativeViewViewConfigAndroid = require('./ReactNativeViewViewConfigAndroid'); + +const registerGeneratedViewConfig = require('../../Utilities/registerGeneratedViewConfig'); const requireNativeComponent = require('../../ReactNative/requireNativeComponent'); import type {ViewProps} from './ViewPropTypes'; @@ -23,7 +24,30 @@ export type ViewNativeComponentType = Class< >; let NativeViewComponent; -let viewConfig; +let viewConfig: + | $TEMPORARY$object<{||}> + | $TEMPORARY$object<{| + bubblingEventTypes?: $ReadOnly<{ + [eventName: string]: $ReadOnly<{| + phasedRegistrationNames: $ReadOnly<{| + bubbled: string, + captured: string, + |}>, + |}>, + }>, + directEventTypes?: $ReadOnly<{ + [eventName: string]: $ReadOnly<{|registrationName: string|}>, + }>, + uiViewClassName: string, + validAttributes?: { + [propName: string]: + | true + | $ReadOnly<{| + diff?: (arg1: any, arg2: any) => boolean, + process?: (arg1: any) => any, + |}>, + }, + |}>; // Only use the JS view config in DEV if (__DEV__) { diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index 58c7b22612f0b2..7060fdd618947d 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -13,7 +13,7 @@ import type {ExtendedError} from './Devtools/parseErrorStack'; class SyntheticError extends Error { - name = ''; + name: string = ''; } /** diff --git a/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js b/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js index 765b8ef0e07ef3..1e5d9b4deca8ad 100644 --- a/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js +++ b/Libraries/Core/SegmentFetcher/NativeSegmentFetcher.js @@ -25,4 +25,4 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.getEnforcing('SegmentFetcher'); +export default (TurboModuleRegistry.getEnforcing('SegmentFetcher'): Spec); diff --git a/Libraries/Core/Timers/JSTimers.js b/Libraries/Core/Timers/JSTimers.js index c13732b2ce8671..e877680f778aad 100644 --- a/Libraries/Core/Timers/JSTimers.js +++ b/Libraries/Core/Timers/JSTimers.js @@ -9,15 +9,14 @@ */ 'use strict'; +const BatchedBridge = require('../../BatchedBridge/BatchedBridge'); const Platform = require('../../Utilities/Platform'); const Systrace = require('../../Performance/Systrace'); const invariant = require('invariant'); -const BatchedBridge = require('../../BatchedBridge/BatchedBridge'); - -import NativeTiming from './NativeTiming'; import type {ExtendedError} from '../Devtools/parseErrorStack'; +import NativeTiming from './NativeTiming'; let _performanceNow = null; function performanceNow() { @@ -498,7 +497,22 @@ function setSendIdleEvents(sendIdleEvents: boolean): void { NativeTiming.setSendIdleEvents(sendIdleEvents); } -let ExportedJSTimers; +let ExportedJSTimers: $TEMPORARY$object<{| + callIdleCallbacks: (frameTime: number) => any | void, + callImmediates: () => void, + callTimers: (timersToCall: Array) => any | void, + cancelAnimationFrame: (timerID: number) => void, + cancelIdleCallback: (timerID: number) => void, + clearImmediate: (timerID: number) => void, + clearInterval: (timerID: number) => void, + clearTimeout: (timerID: number) => void, + emitTimeDriftWarning: (warningMessage: string) => any | void, + requestAnimationFrame: (func: any) => any | number, + requestIdleCallback: (func: any, options: ?any) => any | number, + setImmediate: (func: any, ...args: any) => number, + setInterval: (func: any, duration: number, ...args: any) => number, + setTimeout: (func: any, duration: number, ...args: any) => number, +|}>; if (!NativeTiming) { console.warn("Timing native module is not available, can't set timers."); // $FlowFixMe: we can assume timers are generally available diff --git a/Libraries/Core/Timers/NativeTiming.js b/Libraries/Core/Timers/NativeTiming.js index f02c71e6fca604..0070adb906e615 100644 --- a/Libraries/Core/Timers/NativeTiming.js +++ b/Libraries/Core/Timers/NativeTiming.js @@ -24,4 +24,4 @@ export interface Spec extends TurboModule { +setSendIdleEvents: (sendIdleEvents: boolean) => void; } -export default TurboModuleRegistry.get('Timing'); +export default (TurboModuleRegistry.get('Timing'): ?Spec); diff --git a/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js index 67a016fffc8d24..f4648be20b10a3 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType.js @@ -12,7 +12,12 @@ const PropTypes = require('prop-types'); -const DeprecatedEdgeInsetsPropType = PropTypes.shape({ +const DeprecatedEdgeInsetsPropType: React$PropType$Primitive<{ + bottom?: number, + left?: number, + right?: number, + top?: number, +}> = PropTypes.shape({ top: PropTypes.number, left: PropTypes.number, bottom: PropTypes.number, diff --git a/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.js b/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.js index 49e5f1de6ed415..b2d41020de77f8 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedImagePropType.js @@ -17,9 +17,11 @@ const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); const PropTypes = require('prop-types'); module.exports = { - style: DeprecatedStyleSheetPropType(DeprecatedImageStylePropTypes), + style: (DeprecatedStyleSheetPropType( + DeprecatedImageStylePropTypes, + ): ReactPropsCheckType), source: DeprecatedImageSourcePropType, - defaultSource: PropTypes.oneOfType([ + defaultSource: (PropTypes.oneOfType([ PropTypes.shape({ uri: PropTypes.string, width: PropTypes.number, @@ -27,7 +29,9 @@ module.exports = { scale: PropTypes.number, }), PropTypes.number, - ]), + ]): React$PropType$Primitive< + {height?: number, scale?: number, uri?: string, width?: number} | number, + >), accessible: PropTypes.bool, @@ -37,15 +41,21 @@ module.exports = { capInsets: DeprecatedEdgeInsetsPropType, - resizeMethod: PropTypes.oneOf(['auto', 'resize', 'scale']), + resizeMethod: (PropTypes.oneOf([ + 'auto', + 'resize', + 'scale', + ]): React$PropType$Primitive<'auto' | 'resize' | 'scale'>), - resizeMode: PropTypes.oneOf([ + resizeMode: (PropTypes.oneOf([ 'cover', 'contain', 'stretch', 'repeat', 'center', - ]), + ]): React$PropType$Primitive< + 'cover' | 'contain' | 'stretch' | 'repeat' | 'center', + >), testID: PropTypes.string, diff --git a/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js index eab9d6e49c892b..351542d9bfc7b8 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedImageStylePropTypes.js @@ -11,27 +11,35 @@ const DeprecatedColorPropType = require('./DeprecatedColorPropType'); const DeprecatedLayoutPropTypes = require('./DeprecatedLayoutPropTypes'); -const ReactPropTypes = require('prop-types'); const DeprecatedShadowPropTypesIOS = require('./DeprecatedShadowPropTypesIOS'); const DeprecatedTransformPropTypes = require('./DeprecatedTransformPropTypes'); +const ReactPropTypes = require('prop-types'); const ImageStylePropTypes = { ...DeprecatedLayoutPropTypes, ...DeprecatedShadowPropTypesIOS, ...DeprecatedTransformPropTypes, - resizeMode: ReactPropTypes.oneOf([ + resizeMode: (ReactPropTypes.oneOf([ 'center', 'contain', 'cover', 'repeat', 'stretch', - ]), - backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']), + ]): React$PropType$Primitive< + 'center' | 'contain' | 'cover' | 'repeat' | 'stretch', + >), + backfaceVisibility: (ReactPropTypes.oneOf([ + 'visible', + 'hidden', + ]): React$PropType$Primitive<'visible' | 'hidden'>), backgroundColor: DeprecatedColorPropType, borderColor: DeprecatedColorPropType, borderWidth: ReactPropTypes.number, borderRadius: ReactPropTypes.number, - overflow: ReactPropTypes.oneOf(['visible', 'hidden']), + overflow: (ReactPropTypes.oneOf([ + 'visible', + 'hidden', + ]): React$PropType$Primitive<'visible' | 'hidden'>), /** * Changes the color of all the non-transparent pixels to the tintColor. diff --git a/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js index 0ebccaa8d07083..4d4488a9171f1a 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedLayoutPropTypes.js @@ -13,121 +13,129 @@ const ReactPropTypes = require('prop-types'); const LayoutPropTypes = { - display: ReactPropTypes.oneOf(['none', 'flex']), - width: ReactPropTypes.oneOfType([ + display: (ReactPropTypes.oneOf(['none', 'flex']): React$PropType$Primitive< + 'none' | 'flex', + >), + width: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - height: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + height: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - start: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + start: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - end: ReactPropTypes.oneOfType([ReactPropTypes.number, ReactPropTypes.string]), - top: ReactPropTypes.oneOfType([ReactPropTypes.number, ReactPropTypes.string]), - left: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + end: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - right: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + top: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - bottom: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + left: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - minWidth: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + right: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - maxWidth: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + bottom: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - minHeight: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + minWidth: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - maxHeight: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + maxWidth: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - margin: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + minHeight: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginVertical: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + maxHeight: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginHorizontal: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + margin: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginTop: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginVertical: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginBottom: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginHorizontal: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginLeft: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginTop: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginRight: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginBottom: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginStart: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginLeft: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - marginEnd: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginRight: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - padding: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginStart: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingVertical: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + marginEnd: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingHorizontal: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + padding: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingTop: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + paddingVertical: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingBottom: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + paddingHorizontal: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingLeft: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + paddingTop: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingRight: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + paddingBottom: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingStart: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + paddingLeft: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), - paddingEnd: ReactPropTypes.oneOfType([ + ]): React$PropType$Primitive), + paddingRight: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), + ]): React$PropType$Primitive), + paddingStart: (ReactPropTypes.oneOfType([ + ReactPropTypes.number, + ReactPropTypes.string, + ]): React$PropType$Primitive), + paddingEnd: (ReactPropTypes.oneOfType([ + ReactPropTypes.number, + ReactPropTypes.string, + ]): React$PropType$Primitive), borderWidth: ReactPropTypes.number, borderTopWidth: ReactPropTypes.number, borderStartWidth: ReactPropTypes.number, @@ -135,56 +143,91 @@ const LayoutPropTypes = { borderRightWidth: ReactPropTypes.number, borderBottomWidth: ReactPropTypes.number, borderLeftWidth: ReactPropTypes.number, - position: ReactPropTypes.oneOf(['absolute', 'relative']), - flexDirection: ReactPropTypes.oneOf([ + position: (ReactPropTypes.oneOf([ + 'absolute', + 'relative', + ]): React$PropType$Primitive<'absolute' | 'relative'>), + flexDirection: (ReactPropTypes.oneOf([ 'row', 'row-reverse', 'column', 'column-reverse', - ]), - flexWrap: ReactPropTypes.oneOf(['wrap', 'nowrap', 'wrap-reverse']), - justifyContent: ReactPropTypes.oneOf([ + ]): React$PropType$Primitive< + 'row' | 'row-reverse' | 'column' | 'column-reverse', + >), + flexWrap: (ReactPropTypes.oneOf([ + 'wrap', + 'nowrap', + 'wrap-reverse', + ]): React$PropType$Primitive<'wrap' | 'nowrap' | 'wrap-reverse'>), + justifyContent: (ReactPropTypes.oneOf([ 'flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly', - ]), - alignItems: ReactPropTypes.oneOf([ + ]): React$PropType$Primitive< + | 'flex-start' + | 'flex-end' + | 'center' + | 'space-between' + | 'space-around' + | 'space-evenly', + >), + alignItems: (ReactPropTypes.oneOf([ 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', - ]), - alignSelf: ReactPropTypes.oneOf([ + ]): React$PropType$Primitive< + 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline', + >), + alignSelf: (ReactPropTypes.oneOf([ 'auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline', - ]), - alignContent: ReactPropTypes.oneOf([ + ]): React$PropType$Primitive< + 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline', + >), + alignContent: (ReactPropTypes.oneOf([ 'flex-start', 'flex-end', 'center', 'stretch', 'space-between', 'space-around', - ]), - overflow: ReactPropTypes.oneOf(['visible', 'hidden', 'scroll']), + ]): React$PropType$Primitive< + | 'flex-start' + | 'flex-end' + | 'center' + | 'stretch' + | 'space-between' + | 'space-around', + >), + overflow: (ReactPropTypes.oneOf([ + 'visible', + 'hidden', + 'scroll', + ]): React$PropType$Primitive<'visible' | 'hidden' | 'scroll'>), flex: ReactPropTypes.number, flexGrow: ReactPropTypes.number, flexShrink: ReactPropTypes.number, - flexBasis: ReactPropTypes.oneOfType([ + flexBasis: (ReactPropTypes.oneOfType([ ReactPropTypes.number, ReactPropTypes.string, - ]), + ]): React$PropType$Primitive), aspectRatio: ReactPropTypes.number, zIndex: ReactPropTypes.number, - direction: ReactPropTypes.oneOf(['inherit', 'ltr', 'rtl']), + direction: (ReactPropTypes.oneOf([ + 'inherit', + 'ltr', + 'rtl', + ]): React$PropType$Primitive<'inherit' | 'ltr' | 'rtl'>), }; module.exports = LayoutPropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js b/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js index 9ae8c8f9872d5c..1d13e7ed74a5b9 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedPointPropType.js @@ -12,7 +12,10 @@ const PropTypes = require('prop-types'); -const PointPropType = PropTypes.shape({ +const PointPropType: React$PropType$Primitive<{ + x?: number, + y?: number, +}> = PropTypes.shape({ x: PropTypes.number, y: PropTypes.number, }); diff --git a/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js b/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js index f2d73c9578f935..3d0fe41604733e 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedShadowPropTypesIOS.js @@ -14,10 +14,10 @@ const ReactPropTypes = require('prop-types'); const DeprecatedShadowPropTypesIOS = { shadowColor: DeprecatedColorPropType, - shadowOffset: ReactPropTypes.shape({ + shadowOffset: (ReactPropTypes.shape({ width: ReactPropTypes.number, height: ReactPropTypes.number, - }), + }): React$PropType$Primitive<{height?: number, width?: number}>), shadowOpacity: ReactPropTypes.number, shadowRadius: ReactPropTypes.number, }; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js index 06abb2fc3fd790..7474f53b6fb50c 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTextPropTypes.js @@ -16,12 +16,23 @@ const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); const PropTypes = require('prop-types'); const TextStylePropTypes = require('../Text/TextStylePropTypes'); -const stylePropType = DeprecatedStyleSheetPropType(TextStylePropTypes); +const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( + TextStylePropTypes, +); module.exports = { - ellipsizeMode: PropTypes.oneOf(['head', 'middle', 'tail', 'clip']), + ellipsizeMode: (PropTypes.oneOf([ + 'head', + 'middle', + 'tail', + 'clip', + ]): React$PropType$Primitive<'head' | 'middle' | 'tail' | 'clip'>), numberOfLines: PropTypes.number, - textBreakStrategy: PropTypes.oneOf(['simple', 'highQuality', 'balanced']), + textBreakStrategy: (PropTypes.oneOf([ + 'simple', + 'highQuality', + 'balanced', + ]): React$PropType$Primitive<'simple' | 'highQuality' | 'balanced'>), onLayout: PropTypes.func, onPress: PropTypes.func, onLongPress: PropTypes.func, diff --git a/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js index d4a408f7e9546c..78b445e754b362 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedTransformPropTypes.js @@ -41,7 +41,7 @@ const DecomposedMatrixPropType = function( }; const DeprecatedTransformPropTypes = { - transform: ReactPropTypes.arrayOf( + transform: (ReactPropTypes.arrayOf( ReactPropTypes.oneOfType([ ReactPropTypes.shape({perspective: ReactPropTypes.number}), ReactPropTypes.shape({rotate: ReactPropTypes.string}), @@ -56,29 +56,44 @@ const DeprecatedTransformPropTypes = { ReactPropTypes.shape({skewX: ReactPropTypes.string}), ReactPropTypes.shape({skewY: ReactPropTypes.string}), ]), - ), + ): React$PropType$Primitive< + Array< + | {perspective?: number} + | {rotate?: string} + | {rotateX?: string} + | {rotateY?: string} + | {rotateZ?: string} + | {scale?: number} + | {scaleX?: number} + | {scaleY?: number} + | {translateX?: number} + | {translateY?: number} + | {skewX?: string} + | {skewY?: string}, + >, + >), transformMatrix: TransformMatrixPropType, decomposedMatrix: DecomposedMatrixPropType, - scaleX: deprecatedPropType( + scaleX: (deprecatedPropType( ReactPropTypes.number, 'Use the transform prop instead.', - ), - scaleY: deprecatedPropType( + ): ReactPropsCheckType), + scaleY: (deprecatedPropType( ReactPropTypes.number, 'Use the transform prop instead.', - ), - rotation: deprecatedPropType( + ): ReactPropsCheckType), + rotation: (deprecatedPropType( ReactPropTypes.number, 'Use the transform prop instead.', - ), - translateX: deprecatedPropType( + ): ReactPropsCheckType), + translateX: (deprecatedPropType( ReactPropTypes.number, 'Use the transform prop instead.', - ), - translateY: deprecatedPropType( + ): ReactPropsCheckType), + translateY: (deprecatedPropType( ReactPropTypes.number, 'Use the transform prop instead.', - ), + ): ReactPropsCheckType), }; module.exports = DeprecatedTransformPropTypes; diff --git a/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js index 343513b5cf3570..03fd9a7c1a7691 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedViewPropTypes.js @@ -11,17 +11,17 @@ 'use strict'; const DeprecatedEdgeInsetsPropType = require('./DeprecatedEdgeInsetsPropType'); -const PlatformViewPropTypes = require('../Components/View/PlatformViewPropTypes'); -const PropTypes = require('prop-types'); const DeprecatedStyleSheetPropType = require('./DeprecatedStyleSheetPropType'); const DeprecatedViewStylePropTypes = require('./DeprecatedViewStylePropTypes'); +const PlatformViewPropTypes = require('../Components/View/PlatformViewPropTypes'); +const PropTypes = require('prop-types'); const { DeprecatedAccessibilityRoles, DeprecatedAccessibilityStates, } = require('./DeprecatedViewAccessibility'); -const stylePropType = DeprecatedStyleSheetPropType( +const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( DeprecatedViewStylePropTypes, ); @@ -58,7 +58,9 @@ module.exports = { * * @platform ios */ - accessibilityActions: PropTypes.arrayOf(PropTypes.string), + accessibilityActions: (PropTypes.arrayOf( + PropTypes.string, + ): React$PropType$Primitive>), /** * Prevents view from being inverted if set to true and color inversion is turned on. @@ -70,14 +72,55 @@ module.exports = { /** * Indicates to accessibility services to treat UI component like a specific role. */ - accessibilityRole: PropTypes.oneOf(DeprecatedAccessibilityRoles), + accessibilityRole: (PropTypes.oneOf( + DeprecatedAccessibilityRoles, + ): React$PropType$Primitive< + | 'none' + | 'button' + | 'link' + | 'search' + | 'image' + | 'keyboardkey' + | 'text' + | 'adjustable' + | 'imagebutton' + | 'header' + | 'summary' + | 'alert' + | 'checkbox' + | 'combobox' + | 'menu' + | 'menubar' + | 'menuitem' + | 'progressbar' + | 'radio' + | 'radiogroup' + | 'scrollbar' + | 'spinbutton' + | 'switch' + | 'tab' + | 'tablist' + | 'timer' + | 'toolbar', + >), /** * Indicates to accessibility services that UI Component is in a specific State. */ - accessibilityStates: PropTypes.arrayOf( + accessibilityStates: (PropTypes.arrayOf( PropTypes.oneOf(DeprecatedAccessibilityStates), - ), + ): React$PropType$Primitive< + Array< + | 'selected' + | 'disabled' + | 'checked' + | 'unchecked' + | 'busy' + | 'expanded' + | 'collapsed' + | 'hasPopup', + >, + >), accessibilityState: PropTypes.object, /** * Indicates to accessibility services whether the user should be notified @@ -87,7 +130,11 @@ module.exports = { * * See http://facebook.github.io/react-native/docs/view.html#accessibilityliveregion */ - accessibilityLiveRegion: PropTypes.oneOf(['none', 'polite', 'assertive']), + accessibilityLiveRegion: (PropTypes.oneOf([ + 'none', + 'polite', + 'assertive', + ]): React$PropType$Primitive<'none' | 'polite' | 'assertive'>), /** * Controls how view is important for accessibility which is if it @@ -98,12 +145,12 @@ module.exports = { * * See http://facebook.github.io/react-native/docs/view.html#importantforaccessibility */ - importantForAccessibility: PropTypes.oneOf([ + importantForAccessibility: (PropTypes.oneOf([ 'auto', 'yes', 'no', 'no-hide-descendants', - ]), + ]): React$PropType$Primitive<'auto' | 'yes' | 'no' | 'no-hide-descendants'>), /** * A value indicating whether VoiceOver should ignore the elements @@ -314,7 +361,12 @@ module.exports = { * * See http://facebook.github.io/react-native/docs/view.html#pointerevents */ - pointerEvents: PropTypes.oneOf(['box-none', 'none', 'box-only', 'auto']), + pointerEvents: (PropTypes.oneOf([ + 'box-none', + 'none', + 'box-only', + 'auto', + ]): React$PropType$Primitive<'box-none' | 'none' | 'box-only' | 'auto'>), /** * See http://facebook.github.io/react-native/docs/style.html diff --git a/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js b/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js index 373174edd1eaf2..8b7036bd60761d 100644 --- a/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js +++ b/Libraries/DeprecatedPropTypes/DeprecatedViewStylePropTypes.js @@ -12,9 +12,9 @@ const DeprecatedColorPropType = require('./DeprecatedColorPropType'); const DeprecatedLayoutPropTypes = require('./DeprecatedLayoutPropTypes'); -const ReactPropTypes = require('prop-types'); const DeprecatedShadowPropTypesIOS = require('./DeprecatedShadowPropTypesIOS'); const DeprecatedTransformPropTypes = require('./DeprecatedTransformPropTypes'); +const ReactPropTypes = require('prop-types'); /** * Warning: Some of these properties may not be supported in all releases. @@ -23,7 +23,10 @@ const DeprecatedViewStylePropTypes = { ...DeprecatedLayoutPropTypes, ...DeprecatedShadowPropTypesIOS, ...DeprecatedTransformPropTypes, - backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']), + backfaceVisibility: (ReactPropTypes.oneOf([ + 'visible', + 'hidden', + ]): React$PropType$Primitive<'visible' | 'hidden'>), backgroundColor: DeprecatedColorPropType, borderColor: DeprecatedColorPropType, borderTopColor: DeprecatedColorPropType, @@ -41,7 +44,11 @@ const DeprecatedViewStylePropTypes = { borderBottomRightRadius: ReactPropTypes.number, borderBottomStartRadius: ReactPropTypes.number, borderBottomEndRadius: ReactPropTypes.number, - borderStyle: ReactPropTypes.oneOf(['solid', 'dotted', 'dashed']), + borderStyle: (ReactPropTypes.oneOf([ + 'solid', + 'dotted', + 'dashed', + ]): React$PropType$Primitive<'solid' | 'dotted' | 'dashed'>), borderWidth: ReactPropTypes.number, borderTopWidth: ReactPropTypes.number, borderRightWidth: ReactPropTypes.number, diff --git a/Libraries/EventEmitter/RCTDeviceEventEmitter.js b/Libraries/EventEmitter/RCTDeviceEventEmitter.js index f3192d0bb4f01b..0b4c15d501d6b8 100644 --- a/Libraries/EventEmitter/RCTDeviceEventEmitter.js +++ b/Libraries/EventEmitter/RCTDeviceEventEmitter.js @@ -81,4 +81,4 @@ class RCTDeviceEventEmitter extends EventEmitter { } } -module.exports = new RCTDeviceEventEmitter(); +module.exports = (new RCTDeviceEventEmitter(): RCTDeviceEventEmitter); diff --git a/Libraries/Experimental/Incremental.js b/Libraries/Experimental/Incremental.js index e7f3e82c2126e6..8ccb315d6a8dc0 100644 --- a/Libraries/Experimental/Incremental.js +++ b/Libraries/Experimental/Incremental.js @@ -11,9 +11,8 @@ 'use strict'; const InteractionManager = require('../Interaction/InteractionManager'); -const React = require('react'); - const PropTypes = require('prop-types'); +const React = require('react'); const infoLog = require('../Utilities/infoLog'); @@ -104,11 +103,16 @@ class Incremental extends React.Component { _mounted: boolean; _rendered: boolean; - static defaultProps = { + static defaultProps: $TEMPORARY$object<{|name: string|}> = { name: '', }; - static contextTypes = { + static contextTypes: + | any + | $TEMPORARY$object<{| + incrementalGroup: React$PropType$Primitive, + incrementalGroupEnabled: React$PropType$Primitive, + |}> = { incrementalGroup: PropTypes.object, incrementalGroupEnabled: PropTypes.bool, }; diff --git a/Libraries/Experimental/IncrementalExample.js b/Libraries/Experimental/IncrementalExample.js index 906bb281bcd110..4d551053e4f193 100644 --- a/Libraries/Experimental/IncrementalExample.js +++ b/Libraries/Experimental/IncrementalExample.js @@ -93,8 +93,9 @@ function Block(props: Object) { const Row = (props: Object) => ; class IncrementalExample extends React.Component { - static title = ''; - static description = 'Enables incremental rendering of complex components.'; + static title: string = ''; + static description: string = + 'Enables incremental rendering of complex components.'; start: number; constructor(props: mixed, context: mixed) { super(props, context); diff --git a/Libraries/Experimental/IncrementalPresenter.js b/Libraries/Experimental/IncrementalPresenter.js index a3f8069c93ca74..561da9bbd83f17 100644 --- a/Libraries/Experimental/IncrementalPresenter.js +++ b/Libraries/Experimental/IncrementalPresenter.js @@ -15,9 +15,9 @@ const PropTypes = require('prop-types'); const React = require('react'); const View = require('../Components/View/View'); -import type {Context} from './Incremental'; import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; import type {LayoutEvent} from '../Types/CoreEventTypes'; +import type {Context} from './Incremental'; /** * WARNING: EXPERIMENTAL. Breaking changes will probably happen a lot and will @@ -44,7 +44,12 @@ class IncrementalPresenter extends React.Component { context: Context; _isDone: boolean; - static contextTypes = { + static contextTypes: + | any + | $TEMPORARY$object<{| + incrementalGroup: React$PropType$Primitive, + incrementalGroupEnabled: React$PropType$Primitive, + |}> = { incrementalGroup: PropTypes.object, incrementalGroupEnabled: PropTypes.bool, }; @@ -67,7 +72,7 @@ class IncrementalPresenter extends React.Component { } this.props.onDone && this.props.onDone(); } - render() { + render(): React.Node { let style: ViewStyleProp; if ( this.props.disabled !== true && diff --git a/Libraries/Experimental/WindowedListView.js b/Libraries/Experimental/WindowedListView.js index 5684752ac5b85f..05c2fa038f08b0 100644 --- a/Libraries/Experimental/WindowedListView.js +++ b/Libraries/Experimental/WindowedListView.js @@ -170,7 +170,15 @@ class WindowedListView extends React.Component { _scrollRef: ?ScrollView; _viewabilityHelper: ViewabilityHelper; - static defaultProps = { + static defaultProps: $TEMPORARY$object<{| + disableIncrementalRendering: boolean, + initialNumToRender: number, + maxNumToRender: number, + numToRenderAhead: number, + recomputeRowsBatchingPeriod: number, + renderScrollComponent: (props: any) => React.Node, + viewablePercentThreshold: number, + |}> = { initialNumToRender: 10, maxNumToRender: 30, numToRenderAhead: 10, diff --git a/Libraries/HeapCapture/NativeHeapCapture.js b/Libraries/HeapCapture/NativeHeapCapture.js index 95c2f7f7cff75b..7374cd357297bb 100644 --- a/Libraries/HeapCapture/NativeHeapCapture.js +++ b/Libraries/HeapCapture/NativeHeapCapture.js @@ -21,4 +21,4 @@ export interface Spec extends TurboModule { +captureComplete: (path: string, error: ?string) => void; } -export default TurboModuleRegistry.get('HeapCapture'); +export default (TurboModuleRegistry.get('HeapCapture'): ?Spec); diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 59411e6d6aedf8..e92ef67b336299 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -47,7 +47,7 @@ function getSizeWithHeaders( headers: {[string]: string}, success: (width: number, height: number) => void, failure?: (error: any) => void, -) { +): any { return ImageViewManager.getSizeWithHeaders({uri, headers}) .then(function(sizes) { success(sizes.width, sizes.height); @@ -60,7 +60,7 @@ function getSizeWithHeaders( ); } -function prefetch(url: string) { +function prefetch(url: string): any { return ImageViewManager.prefetchImage(url); } diff --git a/Libraries/Image/ImageBackground.js b/Libraries/Image/ImageBackground.js index 22d684ba90bf32..e6baa48012c608 100644 --- a/Libraries/Image/ImageBackground.js +++ b/Libraries/Image/ImageBackground.js @@ -56,7 +56,7 @@ class ImageBackground extends React.Component<$FlowFixMeProps> { this._viewRef = ref; }; - render() { + render(): React.Node { const {children, style, imageStyle, imageRef, ...props} = this.props; return ( diff --git a/Libraries/Image/ImagePickerIOS.js b/Libraries/Image/ImagePickerIOS.js index 378636d0fcbaa2..587d89b6ed6fe8 100644 --- a/Libraries/Image/ImagePickerIOS.js +++ b/Libraries/Image/ImagePickerIOS.js @@ -14,11 +14,11 @@ import NativeImagePickerIOS from './NativeImagePickerIOS'; import invariant from 'invariant'; const ImagePickerIOS = { - canRecordVideos: function(callback: (result: boolean) => void) { + canRecordVideos: function(callback: (result: boolean) => void): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); return NativeImagePickerIOS.canRecordVideos(callback); }, - canUseCamera: function(callback: (result: boolean) => void) { + canUseCamera: function(callback: (result: boolean) => void): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); return NativeImagePickerIOS.canUseCamera(callback); }, @@ -29,7 +29,7 @@ const ImagePickerIOS = { |}>, successCallback: (imageURL: string, height: number, width: number) => void, cancelCallback: () => void, - ) { + ): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); var newConfig = { @@ -58,7 +58,7 @@ const ImagePickerIOS = { |}>, successCallback: (imageURL: string, height: number, width: number) => void, cancelCallback: () => void, - ) { + ): void { invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available'); var newConfig = { diff --git a/Libraries/Image/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index c0dbee693b7339..06722105bdc229 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -12,6 +12,6 @@ const requireNativeComponent = require('../ReactNative/requireNativeComponent'); -const ImageViewNativeComponent = requireNativeComponent('RCTImageView'); +const ImageViewNativeComponent: string = requireNativeComponent('RCTImageView'); module.exports = ImageViewNativeComponent; diff --git a/Libraries/Image/NativeImagePickerIOS.js b/Libraries/Image/NativeImagePickerIOS.js index 668a2af7e34c9a..895f95f39f69d1 100644 --- a/Libraries/Image/NativeImagePickerIOS.js +++ b/Libraries/Image/NativeImagePickerIOS.js @@ -35,4 +35,4 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.get('ImagePickerIOS'); +export default (TurboModuleRegistry.get('ImagePickerIOS'): ?Spec); diff --git a/Libraries/Image/RelativeImageStub.js b/Libraries/Image/RelativeImageStub.js index 6349a393f59064..040392a75e2e07 100644 --- a/Libraries/Image/RelativeImageStub.js +++ b/Libraries/Image/RelativeImageStub.js @@ -15,7 +15,7 @@ const AssetRegistry = require('./AssetRegistry'); -module.exports = AssetRegistry.registerAsset({ +module.exports = (AssetRegistry.registerAsset({ __packager_asset: true, fileSystemLocation: '/full/path/to/directory', httpServerLocation: '/assets/full/path/to/directory', @@ -25,4 +25,4 @@ module.exports = AssetRegistry.registerAsset({ hash: 'nonsense', name: 'icon', type: 'png', -}); +}): number); diff --git a/Libraries/Image/TextInlineImageNativeComponent.js b/Libraries/Image/TextInlineImageNativeComponent.js index b8cb7a50f8eb59..144e4314f8d645 100644 --- a/Libraries/Image/TextInlineImageNativeComponent.js +++ b/Libraries/Image/TextInlineImageNativeComponent.js @@ -12,6 +12,6 @@ const requireNativeComponent = require('../ReactNative/requireNativeComponent'); -const TextInlineImage = requireNativeComponent('RCTTextInlineImage'); +const TextInlineImage: string = requireNativeComponent('RCTTextInlineImage'); module.exports = TextInlineImage; diff --git a/Libraries/Image/assetPathUtils.js b/Libraries/Image/assetPathUtils.js index 402680cef72779..6281c959984d9c 100644 --- a/Libraries/Image/assetPathUtils.js +++ b/Libraries/Image/assetPathUtils.js @@ -44,7 +44,10 @@ const drawableFileTypes = new Set([ 'xml', ]); -function getAndroidResourceFolderName(asset: PackagerAsset, scale: number) { +function getAndroidResourceFolderName( + asset: PackagerAsset, + scale: number, +): string | $TEMPORARY$string<'raw'> { if (!drawableFileTypes.has(asset.type)) { return 'raw'; } @@ -63,7 +66,7 @@ function getAndroidResourceFolderName(asset: PackagerAsset, scale: number) { return androidFolder; } -function getAndroidResourceIdentifier(asset: PackagerAsset) { +function getAndroidResourceIdentifier(asset: PackagerAsset): string { var folderPath = getBasePath(asset); return (folderPath + '/' + asset.name) .toLowerCase() @@ -72,7 +75,7 @@ function getAndroidResourceIdentifier(asset: PackagerAsset) { .replace(/^assets_/, ''); // Remove "assets_" prefix } -function getBasePath(asset: PackagerAsset) { +function getBasePath(asset: PackagerAsset): string { var basePath = asset.httpServerLocation; if (basePath[0] === '/') { basePath = basePath.substr(1); diff --git a/Libraries/Inspector/BorderBox.js b/Libraries/Inspector/BorderBox.js index 3ab66f10a0fb20..886beb784d5922 100644 --- a/Libraries/Inspector/BorderBox.js +++ b/Libraries/Inspector/BorderBox.js @@ -14,7 +14,7 @@ const React = require('react'); const View = require('../Components/View/View'); class BorderBox extends React.Component<$FlowFixMeProps> { - render() { + render(): $FlowFixMe | React.Node { const box = this.props.box; if (!box) { return this.props.children; diff --git a/Libraries/Inspector/BoxInspector.js b/Libraries/Inspector/BoxInspector.js index bd1f3d376f5f83..e1002f568ca0f4 100644 --- a/Libraries/Inspector/BoxInspector.js +++ b/Libraries/Inspector/BoxInspector.js @@ -14,6 +14,7 @@ const React = require('react'); const StyleSheet = require('../StyleSheet/StyleSheet'); const Text = require('../Text/Text'); const View = require('../Components/View/View'); + const resolveBoxStyle = require('./resolveBoxStyle'); const blank = { @@ -24,7 +25,7 @@ const blank = { }; class BoxInspector extends React.Component<$FlowFixMeProps> { - render() { + render(): React.Node { const frame = this.props.frame; const style = this.props.style; const margin = (style && resolveBoxStyle('margin', style)) || blank; diff --git a/Libraries/Inspector/ElementBox.js b/Libraries/Inspector/ElementBox.js index 9f6c0c4bf204ed..2e67b18f7720d8 100644 --- a/Libraries/Inspector/ElementBox.js +++ b/Libraries/Inspector/ElementBox.js @@ -11,16 +11,16 @@ 'use strict'; const BorderBox = require('./BorderBox'); +const Dimensions = require('../Utilities/Dimensions'); const React = require('react'); const StyleSheet = require('../StyleSheet/StyleSheet'); const View = require('../Components/View/View'); -const Dimensions = require('../Utilities/Dimensions'); const flattenStyle = require('../StyleSheet/flattenStyle'); const resolveBoxStyle = require('./resolveBoxStyle'); class ElementBox extends React.Component<$FlowFixMeProps> { - render() { + render(): React.Node { const style = flattenStyle(this.props.style) || {}; let margin = resolveBoxStyle('margin', style); let padding = resolveBoxStyle('padding', style); diff --git a/Libraries/Inspector/ElementProperties.js b/Libraries/Inspector/ElementProperties.js index 3cc8f4bfa5f1ba..31f74406a9ed11 100644 --- a/Libraries/Inspector/ElementProperties.js +++ b/Libraries/Inspector/ElementProperties.js @@ -38,7 +38,7 @@ type Props = $ReadOnly<{| |}>; class ElementProperties extends React.Component { - render() { + render(): React.Node { const style = flattenStyle(this.props.style); const selection = this.props.selection; let openFileButton; diff --git a/Libraries/Inspector/Inspector.js b/Libraries/Inspector/Inspector.js index a9ddf5919572be..22dd2655b61722 100644 --- a/Libraries/Inspector/Inspector.js +++ b/Libraries/Inspector/Inspector.js @@ -115,7 +115,7 @@ class Inspector extends React.Component< this.setState({inspectedViewTag: newProps.inspectedViewTag}); } - attachToDevtools = (agent: Object) => { + attachToDevtools: (agent: any) => void = (agent: Object) => { let _hideWait = null; const hlSub = agent.sub('highlight', ({node, name, props}) => { clearTimeout(_hideWait); @@ -239,7 +239,7 @@ class Inspector extends React.Component< }); } - render() { + render(): React.Node { const panelContainerStyle = this.state.panelPos === 'bottom' ? {bottom: 0} diff --git a/Libraries/Inspector/InspectorOverlay.js b/Libraries/Inspector/InspectorOverlay.js index 540afb73c1c998..878ee5e6ca1591 100644 --- a/Libraries/Inspector/InspectorOverlay.js +++ b/Libraries/Inspector/InspectorOverlay.js @@ -17,8 +17,8 @@ const StyleSheet = require('../StyleSheet/StyleSheet'); const UIManager = require('../ReactNative/UIManager'); const View = require('../Components/View/View'); -import type {PressEvent} from '../Types/CoreEventTypes'; import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; +import type {PressEvent} from '../Types/CoreEventTypes'; type Inspected = $ReadOnly<{| frame?: Object, @@ -32,7 +32,7 @@ type Props = $ReadOnly<{| |}>; class InspectorOverlay extends React.Component { - findViewForTouchEvent = (e: PressEvent) => { + findViewForTouchEvent: (e: PressEvent) => void = (e: PressEvent) => { const {locationX, locationY} = e.nativeEvent.touches[0]; UIManager.findSubviewIn( this.props.inspectedViewTag, @@ -47,12 +47,12 @@ class InspectorOverlay extends React.Component { ); }; - shouldSetResponser = (e: PressEvent): boolean => { + shouldSetResponser: (e: PressEvent) => boolean = (e: PressEvent): boolean => { this.findViewForTouchEvent(e); return true; }; - render() { + render(): React.Node { let content = null; if (this.props.inspected) { content = ( diff --git a/Libraries/Inspector/InspectorPanel.js b/Libraries/Inspector/InspectorPanel.js index 8aac5987843494..9cf47a83770a0f 100644 --- a/Libraries/Inspector/InspectorPanel.js +++ b/Libraries/Inspector/InspectorPanel.js @@ -51,7 +51,7 @@ type Props = $ReadOnly<{| |}>; class InspectorPanel extends React.Component { - renderWaiting() { + renderWaiting(): React.Node { if (this.props.inspecting) { return ( Tap something to inspect it @@ -60,7 +60,7 @@ class InspectorPanel extends React.Component { return Nothing is inspected; } - render() { + render(): React.Node { let contents; if (this.props.inspected) { contents = ( diff --git a/Libraries/Inspector/NetworkOverlay.js b/Libraries/Inspector/NetworkOverlay.js index a39370bcee8e65..b2956a077614ba 100644 --- a/Libraries/Inspector/NetworkOverlay.js +++ b/Libraries/Inspector/NetworkOverlay.js @@ -103,7 +103,7 @@ class NetworkOverlay extends React.Component { // Map of `xhr._index` -> `index in `this.state.requests`. _xhrIdMap: {[key: number]: number} = {}; - state = { + state: State = { detailRowId: null, requests: [], }; diff --git a/Libraries/Inspector/PerformanceOverlay.js b/Libraries/Inspector/PerformanceOverlay.js index 9d1f63c8c6a435..56b86fb16c53b9 100644 --- a/Libraries/Inspector/PerformanceOverlay.js +++ b/Libraries/Inspector/PerformanceOverlay.js @@ -17,7 +17,7 @@ const Text = require('../Text/Text'); const View = require('../Components/View/View'); class PerformanceOverlay extends React.Component<{}> { - render() { + render(): React.Node { const perfLogs = PerformanceLogger.getTimespans(); const items = []; diff --git a/Libraries/Inspector/StyleInspector.js b/Libraries/Inspector/StyleInspector.js index 332fe22bfed35f..64f001b116d82d 100644 --- a/Libraries/Inspector/StyleInspector.js +++ b/Libraries/Inspector/StyleInspector.js @@ -16,7 +16,7 @@ const Text = require('../Text/Text'); const View = require('../Components/View/View'); class StyleInspector extends React.Component<$FlowFixMeProps> { - render() { + render(): React.Node { if (!this.props.style) { return No style; } diff --git a/Libraries/Interaction/InteractionManager.js b/Libraries/Interaction/InteractionManager.js index a8148dd63af7d1..8784d9bce5351a 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -139,7 +139,7 @@ const InteractionManager = { _deleteInteractionSet.add(handle); }, - addListener: _emitter.addListener.bind(_emitter), + addListener: (_emitter.addListener.bind(_emitter): $FlowFixMe), /** * A positive number will use setTimeout to schedule any tasks after the diff --git a/Libraries/Interaction/PanResponder.js b/Libraries/Interaction/PanResponder.js index 2b20faebe32544..d70797df24cac3 100644 --- a/Libraries/Interaction/PanResponder.js +++ b/Libraries/Interaction/PanResponder.js @@ -383,7 +383,25 @@ const PanResponder = { * accordingly. (numberActiveTouches) may not be totally accurate unless you * are the responder. */ - create(config: PanResponderConfig) { + create( + config: PanResponderConfig, + ): $TEMPORARY$object<{| + getInteractionHandle: () => ?number, + panHandlers: $TEMPORARY$object<{| + onMoveShouldSetResponder: (event: PressEvent) => boolean, + onMoveShouldSetResponderCapture: (event: PressEvent) => boolean, + onResponderEnd: (event: PressEvent) => void, + onResponderGrant: (event: PressEvent) => boolean, + onResponderMove: (event: PressEvent) => void, + onResponderReject: (event: PressEvent) => void, + onResponderRelease: (event: PressEvent) => void, + onResponderStart: (event: PressEvent) => void, + onResponderTerminate: (event: PressEvent) => void, + onResponderTerminationRequest: (event: PressEvent) => boolean, + onStartShouldSetResponder: (event: PressEvent) => boolean, + onStartShouldSetResponderCapture: (event: PressEvent) => boolean, + |}>, + |}> { const interactionState = { handle: (null: ?number), }; diff --git a/Libraries/JSInspector/NetworkAgent.js b/Libraries/JSInspector/NetworkAgent.js index 7f9c63d63f7a4a..4ad89bae6afb36 100644 --- a/Libraries/JSInspector/NetworkAgent.js +++ b/Libraries/JSInspector/NetworkAgent.js @@ -251,7 +251,7 @@ type EnableArgs = { }; class NetworkAgent extends InspectorAgent { - static DOMAIN = 'Network'; + static DOMAIN: $TEMPORARY$string<'Network'> = 'Network'; _sendEvent: EventSender; _interceptor: ?Interceptor; diff --git a/Libraries/LayoutAnimation/LayoutAnimation.js b/Libraries/LayoutAnimation/LayoutAnimation.js index 20018cf566b20c..4cf9b0db4c4708 100644 --- a/Libraries/LayoutAnimation/LayoutAnimation.js +++ b/Libraries/LayoutAnimation/LayoutAnimation.js @@ -10,9 +10,10 @@ 'use strict'; -import Platform from '../Utilities/Platform'; const UIManager = require('../ReactNative/UIManager'); +import Platform from '../Utilities/Platform'; + type Type = | 'spring' | 'linear' @@ -66,8 +67,12 @@ function create( } const Presets = { - easeInEaseOut: create(300, 'easeInEaseOut', 'opacity'), - linear: create(500, 'linear', 'opacity'), + easeInEaseOut: (create( + 300, + 'easeInEaseOut', + 'opacity', + ): LayoutAnimationConfig), + linear: (create(500, 'linear', 'opacity'): LayoutAnimationConfig), spring: { duration: 700, create: { @@ -132,9 +137,15 @@ const LayoutAnimation = { console.error('LayoutAnimation.checkConfig(...) has been disabled.'); }, Presets, - easeInEaseOut: configureNext.bind(null, Presets.easeInEaseOut), - linear: configureNext.bind(null, Presets.linear), - spring: configureNext.bind(null, Presets.spring), + easeInEaseOut: (configureNext.bind(null, Presets.easeInEaseOut): ( + onAnimationDidEnd?: any, + ) => void), + linear: (configureNext.bind(null, Presets.linear): ( + onAnimationDidEnd?: any, + ) => void), + spring: (configureNext.bind(null, Presets.spring): ( + onAnimationDidEnd?: any, + ) => void), }; module.exports = LayoutAnimation; diff --git a/Libraries/Linking/Linking.js b/Libraries/Linking/Linking.js index f15023e55325ec..284f2336a5b3d4 100644 --- a/Libraries/Linking/Linking.js +++ b/Libraries/Linking/Linking.js @@ -117,4 +117,4 @@ class Linking extends NativeEventEmitter { } } -module.exports = new Linking(); +module.exports = (new Linking(): Linking); diff --git a/Libraries/Linking/NativeLinking.js b/Libraries/Linking/NativeLinking.js index f661a45184a583..cbb7c1a00bdc6f 100644 --- a/Libraries/Linking/NativeLinking.js +++ b/Libraries/Linking/NativeLinking.js @@ -32,6 +32,6 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default (Platform.OS === 'android' +export default ((Platform.OS === 'android' ? TurboModuleRegistry.getEnforcing('IntentAndroid') - : TurboModuleRegistry.getEnforcing('LinkingManager')); + : TurboModuleRegistry.getEnforcing('LinkingManager')): Spec); diff --git a/Libraries/Lists/__flowtests__/FlatList-flowtest.js b/Libraries/Lists/__flowtests__/FlatList-flowtest.js index 71b5f10004cbe2..99db43079f5f70 100644 --- a/Libraries/Lists/__flowtests__/FlatList-flowtest.js +++ b/Libraries/Lists/__flowtests__/FlatList-flowtest.js @@ -18,7 +18,7 @@ function renderMyListItem(info: {item: {title: string}, index: number}) { } module.exports = { - testEverythingIsFine() { + testEverythingIsFine(): React.Node { const data = [ { title: 'Title Text', @@ -28,7 +28,7 @@ module.exports = { return ; }, - testBadDataWithTypicalItem() { + testBadDataWithTypicalItem(): React.Node { const data = [ { // $FlowExpectedError - bad title type 6, should be string @@ -39,7 +39,7 @@ module.exports = { return ; }, - testMissingFieldWithTypicalItem() { + testMissingFieldWithTypicalItem(): React.Node { const data = [ { key: 1, @@ -49,7 +49,7 @@ module.exports = { return ; }, - testGoodDataWithBadCustomRenderItemFunction() { + testGoodDataWithBadCustomRenderItemFunction(): React.Node { const data = [ { widget: 6, @@ -71,7 +71,7 @@ module.exports = { ); }, - testBadRenderItemFunction() { + testBadRenderItemFunction(): $TEMPORARY$array { const data = [ { title: 'foo', @@ -99,7 +99,7 @@ module.exports = { ]; }, - testOtherBadProps() { + testOtherBadProps(): $TEMPORARY$array { return [ // $FlowExpectedError - bad numColumns type "lots" , diff --git a/Libraries/Lists/__flowtests__/SectionList-flowtest.js b/Libraries/Lists/__flowtests__/SectionList-flowtest.js index 9f70f43551fed1..44d8d008b7ba03 100644 --- a/Libraries/Lists/__flowtests__/SectionList-flowtest.js +++ b/Libraries/Lists/__flowtests__/SectionList-flowtest.js @@ -22,7 +22,7 @@ const renderMyHeader = ({section}: {section: {fooNumber: number} & Object}) => ( ); module.exports = { - testGoodDataWithGoodItem() { + testGoodDataWithGoodItem(): React.Node { const sections = [ { key: 'a', @@ -37,7 +37,7 @@ module.exports = { return ; }, - testBadRenderItemFunction() { + testBadRenderItemFunction(): $TEMPORARY$array { const sections = [ { key: 'a', diff --git a/Libraries/Modal/Modal.js b/Libraries/Modal/Modal.js index b5282e3bc0070f..e21ed2ced51564 100644 --- a/Libraries/Modal/Modal.js +++ b/Libraries/Modal/Modal.js @@ -12,18 +12,17 @@ const AppContainer = require('../ReactNative/AppContainer'); const I18nManager = require('../ReactNative/I18nManager'); -const React = require('react'); const PropTypes = require('prop-types'); +const React = require('react'); const ScrollView = require('../Components/ScrollView/ScrollView'); const StyleSheet = require('../StyleSheet/StyleSheet'); const View = require('../Components/View/View'); -import RCTModalHostView from './RCTModalHostViewNativeComponent'; - -import type EmitterSubscription from '../vendor/emitter/EmitterSubscription'; import type {ViewProps} from '../Components/View/ViewPropTypes'; -import type {SyntheticEvent} from '../Types/CoreEventTypes'; import type {DirectEventHandler} from '../Types/CodegenTypes'; +import type {SyntheticEvent} from '../Types/CoreEventTypes'; +import type EmitterSubscription from '../vendor/emitter/EmitterSubscription'; +import RCTModalHostView from './RCTModalHostViewNativeComponent'; /** * The Modal component is a simple way to present content above an enclosing view. * @@ -138,12 +137,17 @@ export type Props = $ReadOnly<{| |}>; class Modal extends React.Component { - static defaultProps = { + static defaultProps: $TEMPORARY$object<{| + hardwareAccelerated: boolean, + visible: boolean, + |}> = { visible: true, hardwareAccelerated: false, }; - static contextTypes = { + static contextTypes: + | any + | $TEMPORARY$object<{|rootTag: React$PropType$Primitive|}> = { rootTag: PropTypes.number, }; @@ -156,11 +160,13 @@ class Modal extends React.Component { this._identifier = uniqueModalIdentifier++; } - static childContextTypes = { + static childContextTypes: + | any + | $TEMPORARY$object<{|virtualizedList: React$PropType$Primitive|}> = { virtualizedList: PropTypes.object, }; - getChildContext() { + getChildContext(): $TEMPORARY$object<{|virtualizedList: null|}> { // Reset the context so VirtualizedList doesn't get confused by nesting // in the React tree that doesn't reflect the native component hierarchy. return { diff --git a/Libraries/Modal/NativeModalManager.js b/Libraries/Modal/NativeModalManager.js index d293caf68f45c3..5f4e6c146fcc0e 100644 --- a/Libraries/Modal/NativeModalManager.js +++ b/Libraries/Modal/NativeModalManager.js @@ -19,4 +19,4 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.get('ModalManager'); +export default (TurboModuleRegistry.get('ModalManager'): ?Spec); diff --git a/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js b/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js index cb653ffe9ad0b4..f814d567df056a 100644 --- a/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js +++ b/Libraries/NativeModules/specs/NativeAnimationsDebugModule.js @@ -18,4 +18,4 @@ export interface Spec extends TurboModule { +stopRecordingFps: (animationStopTimeMs: number) => void; } -export default TurboModuleRegistry.get('AnimationsDebugModule'); +export default (TurboModuleRegistry.get('AnimationsDebugModule'): ?Spec); diff --git a/Libraries/NativeModules/specs/NativeDevSettings.js b/Libraries/NativeModules/specs/NativeDevSettings.js index 9a53a0db7905e0..ec0f9392e8c492 100644 --- a/Libraries/NativeModules/specs/NativeDevSettings.js +++ b/Libraries/NativeModules/specs/NativeDevSettings.js @@ -25,4 +25,4 @@ export interface Spec extends TurboModule { +setIsShakeToShowDevMenuEnabled: (enabled: boolean) => void; } -export default TurboModuleRegistry.getEnforcing('DevSettings'); +export default (TurboModuleRegistry.getEnforcing('DevSettings'): Spec); diff --git a/Libraries/NativeModules/specs/NativeDeviceEventManager.js b/Libraries/NativeModules/specs/NativeDeviceEventManager.js index 1755ba1fc403a8..342115dd0e478e 100644 --- a/Libraries/NativeModules/specs/NativeDeviceEventManager.js +++ b/Libraries/NativeModules/specs/NativeDeviceEventManager.js @@ -17,4 +17,4 @@ export interface Spec extends TurboModule { +invokeDefaultBackPressHandler: () => void; } -export default TurboModuleRegistry.get('DeviceEventManager'); +export default (TurboModuleRegistry.get('DeviceEventManager'): ?Spec); diff --git a/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js b/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js index d1bc7959f7ddda..4ca12692fa1773 100644 --- a/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js +++ b/Libraries/NativeModules/specs/NativeDialogManagerAndroid.js @@ -46,4 +46,4 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.get('DialogManagerAndroid'); +export default (TurboModuleRegistry.get('DialogManagerAndroid'): ?Spec); diff --git a/Libraries/NativeModules/specs/NativeRedBox.js b/Libraries/NativeModules/specs/NativeRedBox.js index 336caca5dcf5d0..e132b544345324 100644 --- a/Libraries/NativeModules/specs/NativeRedBox.js +++ b/Libraries/NativeModules/specs/NativeRedBox.js @@ -18,4 +18,4 @@ export interface Spec extends TurboModule { +dismiss: () => void; } -export default TurboModuleRegistry.get('RedBox'); +export default (TurboModuleRegistry.get('RedBox'): ?Spec); diff --git a/Libraries/NativeModules/specs/NativeSourceCode.js b/Libraries/NativeModules/specs/NativeSourceCode.js index e0383ace4a87d3..2ba94687afb6ea 100644 --- a/Libraries/NativeModules/specs/NativeSourceCode.js +++ b/Libraries/NativeModules/specs/NativeSourceCode.js @@ -19,4 +19,4 @@ export interface Spec extends TurboModule { |}; } -export default TurboModuleRegistry.getEnforcing('SourceCode'); +export default (TurboModuleRegistry.getEnforcing('SourceCode'): Spec); diff --git a/Libraries/Network/NativeNetworkingAndroid.js b/Libraries/Network/NativeNetworkingAndroid.js index 6b0eded7289dac..573090d7d26ccd 100644 --- a/Libraries/Network/NativeNetworkingAndroid.js +++ b/Libraries/Network/NativeNetworkingAndroid.js @@ -35,4 +35,4 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.getEnforcing('Networking'); +export default (TurboModuleRegistry.getEnforcing('Networking'): Spec); diff --git a/Libraries/Network/NativeNetworkingIOS.js b/Libraries/Network/NativeNetworkingIOS.js index 8a2269c6dcaff0..85a6cffbd22034 100644 --- a/Libraries/Network/NativeNetworkingIOS.js +++ b/Libraries/Network/NativeNetworkingIOS.js @@ -35,4 +35,4 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.getEnforcing('Networking'); +export default (TurboModuleRegistry.getEnforcing('Networking'): Spec); diff --git a/Libraries/Network/RCTNetworking.ios.js b/Libraries/Network/RCTNetworking.ios.js index 3abaeb0b0c3c34..73a33ab1d9fbe5 100644 --- a/Libraries/Network/RCTNetworking.ios.js +++ b/Libraries/Network/RCTNetworking.ios.js @@ -11,12 +11,12 @@ 'use strict'; const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter'); -import NativeNetworkingIOS from './NativeNetworkingIOS'; -const convertRequestBody = require('./convertRequestBody'); -import type {RequestBody} from './convertRequestBody'; +const convertRequestBody = require('./convertRequestBody'); +import NativeNetworkingIOS from './NativeNetworkingIOS'; import type {NativeResponseType} from './XMLHttpRequest'; +import type {RequestBody} from './convertRequestBody'; class RCTNetworking extends NativeEventEmitter { constructor() { @@ -60,4 +60,4 @@ class RCTNetworking extends NativeEventEmitter { } } -module.exports = new RCTNetworking(); +module.exports = (new RCTNetworking(): RCTNetworking); diff --git a/Libraries/Network/XMLHttpRequest.js b/Libraries/Network/XMLHttpRequest.js index f0f507cd873895..14e06222b684d8 100644 --- a/Libraries/Network/XMLHttpRequest.js +++ b/Libraries/Network/XMLHttpRequest.js @@ -10,13 +10,13 @@ 'use strict'; +const BlobManager = require('../Blob/BlobManager'); const EventTarget = require('event-target-shim'); const RCTNetworking = require('./RCTNetworking'); const base64 = require('base64-js'); const invariant = require('invariant'); const warning = require('fbjs/lib/warning'); -const BlobManager = require('../Blob/BlobManager'); export type NativeResponseType = 'base64' | 'blob' | 'text'; export type ResponseType = @@ -73,7 +73,7 @@ const REQUEST_EVENTS = [ const XHR_EVENTS = REQUEST_EVENTS.concat('readystatechange'); -class XMLHttpRequestEventTarget extends EventTarget(...REQUEST_EVENTS) { +class XMLHttpRequestEventTarget extends (EventTarget(...REQUEST_EVENTS): any) { onload: ?Function; onloadstart: ?Function; onprogress: ?Function; @@ -86,7 +86,7 @@ class XMLHttpRequestEventTarget extends EventTarget(...REQUEST_EVENTS) { /** * Shared base for platform-specific XMLHttpRequest implementations. */ -class XMLHttpRequest extends EventTarget(...XHR_EVENTS) { +class XMLHttpRequest extends (EventTarget(...XHR_EVENTS): any) { static UNSENT: number = UNSENT; static OPENED: number = OPENED; static HEADERS_RECEIVED: number = HEADERS_RECEIVED; diff --git a/Libraries/Performance/NativeJSCSamplingProfiler.js b/Libraries/Performance/NativeJSCSamplingProfiler.js index 944d68383bcefa..a40e8e301520b8 100644 --- a/Libraries/Performance/NativeJSCSamplingProfiler.js +++ b/Libraries/Performance/NativeJSCSamplingProfiler.js @@ -17,4 +17,4 @@ export interface Spec extends TurboModule { +operationComplete: (token: number, result: ?string, error: ?string) => void; } -export default TurboModuleRegistry.get('JSCSamplingProfiler'); +export default (TurboModuleRegistry.get('JSCSamplingProfiler'): ?Spec); diff --git a/Libraries/PermissionsAndroid/NativePermissionsAndroid.js b/Libraries/PermissionsAndroid/NativePermissionsAndroid.js index 4212164d8baf83..685cb56be00e6d 100644 --- a/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +++ b/Libraries/PermissionsAndroid/NativePermissionsAndroid.js @@ -56,4 +56,4 @@ export interface Spec extends TurboModule { ) => Promise<{[permission: PermissionType]: PermissionStatus}>; } -export default TurboModuleRegistry.get('PermissionsAndroid'); +export default (TurboModuleRegistry.get('PermissionsAndroid'): ?Spec); diff --git a/Libraries/PermissionsAndroid/PermissionsAndroid.js b/Libraries/PermissionsAndroid/PermissionsAndroid.js index 427fb21c8a1f88..9ba1624c62b852 100644 --- a/Libraries/PermissionsAndroid/PermissionsAndroid.js +++ b/Libraries/PermissionsAndroid/PermissionsAndroid.js @@ -10,16 +10,15 @@ 'use strict'; -import NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManagerAndroid'; const Platform = require('../Utilities/Platform'); -import NativePermissionsAndroid from './NativePermissionsAndroid'; - -import invariant from 'invariant'; +import NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManagerAndroid'; +import NativePermissionsAndroid from './NativePermissionsAndroid'; import type { PermissionStatus, PermissionType, } from './NativePermissionsAndroid'; +import invariant from 'invariant'; export type Rationale = { title: string, @@ -69,8 +68,37 @@ const PERMISSIONS = Object.freeze({ */ class PermissionsAndroid { - PERMISSIONS = PERMISSIONS; - RESULTS = PERMISSION_REQUEST_RESULT; + PERMISSIONS: {| + ACCESS_COARSE_LOCATION: string, + ACCESS_FINE_LOCATION: string, + ADD_VOICEMAIL: string, + BODY_SENSORS: string, + CALL_PHONE: string, + CAMERA: string, + GET_ACCOUNTS: string, + PROCESS_OUTGOING_CALLS: string, + READ_CALENDAR: string, + READ_CALL_LOG: string, + READ_CONTACTS: string, + READ_EXTERNAL_STORAGE: string, + READ_PHONE_STATE: string, + READ_SMS: string, + RECEIVE_MMS: string, + RECEIVE_SMS: string, + RECEIVE_WAP_PUSH: string, + RECORD_AUDIO: string, + SEND_SMS: string, + USE_SIP: string, + WRITE_CALENDAR: string, + WRITE_CALL_LOG: string, + WRITE_CONTACTS: string, + WRITE_EXTERNAL_STORAGE: string, + |} = PERMISSIONS; + RESULTS: {| + DENIED: $TEMPORARY$string<'denied'>, + GRANTED: $TEMPORARY$string<'granted'>, + NEVER_ASK_AGAIN: $TEMPORARY$string<'never_ask_again'>, + |} = PERMISSION_REQUEST_RESULT; /** * DEPRECATED - use check diff --git a/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js b/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js index 8d7ea0adbf7144..8eb5095163681c 100644 --- a/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js +++ b/Libraries/PushNotificationIOS/NativePushNotificationManagerIOS.js @@ -8,8 +8,8 @@ * @flow */ -import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; import type {TurboModule} from '../TurboModule/RCTExport'; +import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry'; type Permissions = {| alert: boolean, @@ -69,4 +69,6 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.get('PushNotificationManager'); +export default (TurboModuleRegistry.get( + 'PushNotificationManager', +): ?Spec); diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index a5e792de7c564a..39d3374a864a1d 100644 --- a/Libraries/ReactNative/AppContainer.js +++ b/Libraries/ReactNative/AppContainer.js @@ -42,7 +42,9 @@ class AppContainer extends React.Component { _mainRef: ?React.ElementRef; _subscription: ?EmitterSubscription = null; - static childContextTypes = { + static childContextTypes: + | any + | $TEMPORARY$object<{|rootTag: React$PropType$Primitive|}> = { rootTag: PropTypes.number, }; diff --git a/Libraries/ReactNative/DummyUIManager.js b/Libraries/ReactNative/DummyUIManager.js index 38f93adc54a016..fb2a774b916fd9 100644 --- a/Libraries/ReactNative/DummyUIManager.js +++ b/Libraries/ReactNative/DummyUIManager.js @@ -10,15 +10,15 @@ 'use strict'; module.exports = { - getViewManagerConfig: (viewManagerName: string) => { + getViewManagerConfig: (viewManagerName: string): null => { console.warn( 'Attempting to get config for view manager: ' + viewManagerName, ); return null; }, - getConstants: () => ({}), + getConstants: (): $TEMPORARY$object<{||}> => ({}), getConstantsForViewManager: (viewManagerName: string) => {}, - getDefaultEventTypes: () => [], + getDefaultEventTypes: (): Array<$FlowFixMe> => [], playTouchSound: () => {}, lazilyLoadView: (name: string) => {}, createView: ( diff --git a/Libraries/ReactNative/I18nManager.js b/Libraries/ReactNative/I18nManager.js index f5616c807ae57e..94133b1dd1f421 100644 --- a/Libraries/ReactNative/I18nManager.js +++ b/Libraries/ReactNative/I18nManager.js @@ -11,7 +11,10 @@ import NativeI18nManager from './NativeI18nManager'; -const i18nConstants = NativeI18nManager +const i18nConstants: {| + doLeftAndRightSwapInRTL: boolean, + isRTL: boolean, +|} = NativeI18nManager ? NativeI18nManager.getConstants() : { isRTL: false, @@ -19,7 +22,7 @@ const i18nConstants = NativeI18nManager }; module.exports = { - getConstants: () => { + getConstants: (): {|doLeftAndRightSwapInRTL: boolean, isRTL: boolean|} => { return i18nConstants; }, diff --git a/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js b/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js index d3256f49e10046..290957fd7f2414 100644 --- a/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js +++ b/Libraries/ReactNative/NativeHeadlessJsTaskSupport.js @@ -18,4 +18,4 @@ export interface Spec extends TurboModule { +notifyTaskRetry: (taskId: number) => Promise; } -export default TurboModuleRegistry.get('HeadlessJsTaskSupport'); +export default (TurboModuleRegistry.get('HeadlessJsTaskSupport'): ?Spec); diff --git a/Libraries/ReactNative/NativeI18nManager.js b/Libraries/ReactNative/NativeI18nManager.js index 9da9a6ade2b960..afaab21dfce13f 100644 --- a/Libraries/ReactNative/NativeI18nManager.js +++ b/Libraries/ReactNative/NativeI18nManager.js @@ -23,4 +23,4 @@ export interface Spec extends TurboModule { swapLeftAndRightInRTL: (flipStyles: boolean) => void; } -export default TurboModuleRegistry.get('I18nManager'); +export default (TurboModuleRegistry.get('I18nManager'): ?Spec); diff --git a/Libraries/ReactNative/NativeUIManager.js b/Libraries/ReactNative/NativeUIManager.js index ad6740747b5c70..717e63dbc12282 100644 --- a/Libraries/ReactNative/NativeUIManager.js +++ b/Libraries/ReactNative/NativeUIManager.js @@ -119,4 +119,4 @@ export interface Spec extends TurboModule { +dismissPopupMenu: () => void; } -export default TurboModuleRegistry.getEnforcing('UIManager'); +export default (TurboModuleRegistry.getEnforcing('UIManager'): Spec); diff --git a/Libraries/ReactNative/PaperUIManager.js b/Libraries/ReactNative/PaperUIManager.js index 5e80795ec2990f..9d2a65aded3fd4 100644 --- a/Libraries/ReactNative/PaperUIManager.js +++ b/Libraries/ReactNative/PaperUIManager.js @@ -36,7 +36,7 @@ const UIManagerJS = { getConstants(): Object { return getConstants(); }, - getViewManagerConfig: function(viewManagerName: string) { + getViewManagerConfig: function(viewManagerName: string): any { if ( viewManagerConfigs[viewManagerName] === undefined && NativeUIManager.getConstantsForViewManager diff --git a/Libraries/ReactNative/RootTagContext.js b/Libraries/ReactNative/RootTagContext.js index f85a8c73ea0a35..ca5ed03932fd5c 100644 --- a/Libraries/ReactNative/RootTagContext.js +++ b/Libraries/ReactNative/RootTagContext.js @@ -12,4 +12,4 @@ const React = require('react'); -module.exports = React.createContext(0); +module.exports = (React.createContext(0): React$Context); diff --git a/Libraries/ReactNative/getNativeComponentAttributes.js b/Libraries/ReactNative/getNativeComponentAttributes.js index 9dba82c47507e4..226e3ba9342b42 100644 --- a/Libraries/ReactNative/getNativeComponentAttributes.js +++ b/Libraries/ReactNative/getNativeComponentAttributes.js @@ -14,16 +14,16 @@ const ReactNativeStyleAttributes = require('../Components/View/ReactNativeStyleA const UIManager = require('./UIManager'); const insetsDiffer = require('../Utilities/differ/insetsDiffer'); +const invariant = require('invariant'); const matricesDiffer = require('../Utilities/differ/matricesDiffer'); const pointsDiffer = require('../Utilities/differ/pointsDiffer'); const processColor = require('../StyleSheet/processColor'); const processColorArray = require('../StyleSheet/processColorArray'); const resolveAssetSource = require('../Image/resolveAssetSource'); const sizesDiffer = require('../Utilities/differ/sizesDiffer'); -const invariant = require('invariant'); const warning = require('fbjs/lib/warning'); -function getNativeComponentAttributes(uiViewClassName: string) { +function getNativeComponentAttributes(uiViewClassName: string): any { const viewConfig = UIManager.getViewManagerConfig(uiViewClassName); invariant( diff --git a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js index 5ebc0d36d39fee..c1e192abae644b 100644 --- a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +++ b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js @@ -20,8 +20,8 @@ import type { const invariant = require('invariant'); // Event configs -const customBubblingEventTypes = {}; -const customDirectEventTypes = {}; +const customBubblingEventTypes: $TEMPORARY$object<{||}> = {}; +const customDirectEventTypes: $TEMPORARY$object<{||}> = {}; exports.customBubblingEventTypes = customBubblingEventTypes; exports.customDirectEventTypes = customDirectEventTypes; diff --git a/Libraries/Settings/NativeSettingsManager.js b/Libraries/Settings/NativeSettingsManager.js index 19de825248cdb9..1edd6187218962 100644 --- a/Libraries/Settings/NativeSettingsManager.js +++ b/Libraries/Settings/NativeSettingsManager.js @@ -21,4 +21,6 @@ export interface Spec extends TurboModule { +deleteValues: (values: Array) => void; } -export default TurboModuleRegistry.getEnforcing('SettingsManager'); +export default (TurboModuleRegistry.getEnforcing( + 'SettingsManager', +): Spec); diff --git a/Libraries/Settings/Settings.ios.js b/Libraries/Settings/Settings.ios.js index c802759f764d1b..55d8ff0481d2e1 100644 --- a/Libraries/Settings/Settings.ios.js +++ b/Libraries/Settings/Settings.ios.js @@ -11,15 +11,16 @@ 'use strict'; const RCTDeviceEventEmitter = require('../EventEmitter/RCTDeviceEventEmitter'); -import NativeSettingsManager from './NativeSettingsManager'; const invariant = require('invariant'); +import NativeSettingsManager from './NativeSettingsManager'; + const subscriptions: Array<{keys: Array, callback: ?Function}> = []; const Settings = { - _settings: - NativeSettingsManager && NativeSettingsManager.getConstants().settings, + _settings: (NativeSettingsManager && + NativeSettingsManager.getConstants().settings: any), get(key: string): mixed { return this._settings[key]; diff --git a/Libraries/Share/NativeShareModule.js b/Libraries/Share/NativeShareModule.js index 291a0e01cfaef6..88293b8ce87bac 100644 --- a/Libraries/Share/NativeShareModule.js +++ b/Libraries/Share/NativeShareModule.js @@ -21,4 +21,4 @@ export interface Spec extends TurboModule { ) => Promise<{|action: string|}>; } -export default TurboModuleRegistry.get('ShareModule'); +export default (TurboModuleRegistry.get('ShareModule'): ?Spec); diff --git a/Libraries/Storage/NativeAsyncStorage.js b/Libraries/Storage/NativeAsyncStorage.js index a1c4e51ff9bbca..e7c8e567bbfefd 100644 --- a/Libraries/Storage/NativeAsyncStorage.js +++ b/Libraries/Storage/NativeAsyncStorage.js @@ -40,5 +40,5 @@ export interface Spec extends TurboModule { ) => void; } -export default TurboModuleRegistry.get('AsyncSQLiteDBStorage') || - TurboModuleRegistry.get('AsyncLocalStorage'); +export default (TurboModuleRegistry.get('AsyncSQLiteDBStorage') || + TurboModuleRegistry.get('AsyncLocalStorage'): ?Spec); diff --git a/Libraries/StyleSheet/StyleSheet.js b/Libraries/StyleSheet/StyleSheet.js index 3c3352e37df389..deb6d8cc4e837a 100644 --- a/Libraries/StyleSheet/StyleSheet.js +++ b/Libraries/StyleSheet/StyleSheet.js @@ -151,7 +151,7 @@ export type ImageStyle = ____ImageStyle_Internal; */ export type DangerouslyImpreciseStyle = ____DangerouslyImpreciseStyle_Internal; -let hairlineWidth = PixelRatio.roundToNearestPixel(0.4); +let hairlineWidth: number = PixelRatio.roundToNearestPixel(0.4); if (hairlineWidth === 0) { hairlineWidth = 1 / PixelRatio.get(); } diff --git a/Libraries/Text/TextAncestor.js b/Libraries/Text/TextAncestor.js index 5a8e79eee2ca7a..24fb1b45512fad 100644 --- a/Libraries/Text/TextAncestor.js +++ b/Libraries/Text/TextAncestor.js @@ -18,4 +18,4 @@ const React = require('react'); /* $FlowFixMe(>=0.85.0 site=react_native_fb) This comment suppresses an error * found when Flow v0.85 was deployed. To see the error, delete this comment * and run Flow. */ -module.exports = React.createContext(false); +module.exports = (React.createContext(false): React$Context<$FlowFixMe>); diff --git a/Libraries/Text/TextPropTypes.js b/Libraries/Text/TextPropTypes.js index 756d95721f1b27..216ac303f84fe8 100644 --- a/Libraries/Text/TextPropTypes.js +++ b/Libraries/Text/TextPropTypes.js @@ -12,11 +12,13 @@ const DeprecatedColorPropType = require('../DeprecatedPropTypes/DeprecatedColorPropType'); const DeprecatedEdgeInsetsPropType = require('../DeprecatedPropTypes/DeprecatedEdgeInsetsPropType'); -const PropTypes = require('prop-types'); const DeprecatedStyleSheetPropType = require('../DeprecatedPropTypes/DeprecatedStyleSheetPropType'); +const PropTypes = require('prop-types'); const TextStylePropTypes = require('./TextStylePropTypes'); -const stylePropType = DeprecatedStyleSheetPropType(TextStylePropTypes); +const stylePropType: ReactPropsCheckType = DeprecatedStyleSheetPropType( + TextStylePropTypes, +); const DataDetectorTypes = ['phoneNumber', 'link', 'email', 'none', 'all']; @@ -27,7 +29,12 @@ module.exports = { * * See https://facebook.github.io/react-native/docs/text.html#ellipsizemode */ - ellipsizeMode: PropTypes.oneOf(['head', 'middle', 'tail', 'clip']), + ellipsizeMode: (PropTypes.oneOf([ + 'head', + 'middle', + 'tail', + 'clip', + ]): React$PropType$Primitive<'head' | 'middle' | 'tail' | 'clip'>), /** * Used to truncate the text with an ellipsis. * @@ -39,7 +46,11 @@ module.exports = { * * See https://facebook.github.io/react-native/docs/text.html#textbreakstrategy */ - textBreakStrategy: PropTypes.oneOf(['simple', 'highQuality', 'balanced']), + textBreakStrategy: (PropTypes.oneOf([ + 'simple', + 'highQuality', + 'balanced', + ]): React$PropType$Primitive<'simple' | 'highQuality' | 'balanced'>), /** * Invoked on mount and layout changes. * @@ -139,5 +150,9 @@ module.exports = { * * See https://facebook.github.io/react-native/docs/text.html#dataDetectorType */ - dataDetectorType: PropTypes.oneOf(DataDetectorTypes), + dataDetectorType: (PropTypes.oneOf( + DataDetectorTypes, + ): React$PropType$Primitive< + 'phoneNumber' | 'link' | 'email' | 'none' | 'all', + >), }; diff --git a/Libraries/Text/TextStylePropTypes.js b/Libraries/Text/TextStylePropTypes.js index e41f6d833cc5d0..d1ad5ba5bf9c3b 100644 --- a/Libraries/Text/TextStylePropTypes.js +++ b/Libraries/Text/TextStylePropTypes.js @@ -11,8 +11,8 @@ 'use strict'; const DeprecatedColorPropType = require('../DeprecatedPropTypes/DeprecatedColorPropType'); -const ReactPropTypes = require('prop-types'); const DeprecatedViewStylePropTypes = require('../DeprecatedPropTypes/DeprecatedViewStylePropTypes'); +const ReactPropTypes = require('prop-types'); const TextStylePropTypes = { ...DeprecatedViewStylePropTypes, @@ -20,13 +20,16 @@ const TextStylePropTypes = { color: DeprecatedColorPropType, fontFamily: ReactPropTypes.string, fontSize: ReactPropTypes.number, - fontStyle: ReactPropTypes.oneOf(['normal', 'italic']), + fontStyle: (ReactPropTypes.oneOf([ + 'normal', + 'italic', + ]): React$PropType$Primitive<'normal' | 'italic'>), /** * Specifies font weight. The values 'normal' and 'bold' are supported for * most fonts. Not all fonts have a variant for each of the numeric values, * in that case the closest one is chosen. */ - fontWeight: ReactPropTypes.oneOf([ + fontWeight: (ReactPropTypes.oneOf([ 'normal' /*default*/, 'bold', '100', @@ -38,11 +41,23 @@ const TextStylePropTypes = { '700', '800', '900', - ]), + ]): React$PropType$Primitive< + | 'normal' + | 'bold' + | '100' + | '200' + | '300' + | '400' + | '500' + | '600' + | '700' + | '800' + | '900', + >), /** * @platform ios */ - fontVariant: ReactPropTypes.arrayOf( + fontVariant: (ReactPropTypes.arrayOf( ReactPropTypes.oneOf([ 'small-caps', 'oldstyle-nums', @@ -50,11 +65,19 @@ const TextStylePropTypes = { 'tabular-nums', 'proportional-nums', ]), - ), - textShadowOffset: ReactPropTypes.shape({ + ): React$PropType$Primitive< + Array< + | 'small-caps' + | 'oldstyle-nums' + | 'lining-nums' + | 'tabular-nums' + | 'proportional-nums', + >, + >), + textShadowOffset: (ReactPropTypes.shape({ width: ReactPropTypes.number, height: ReactPropTypes.number, - }), + }): React$PropType$Primitive<{height?: number, width?: number}>), textShadowRadius: ReactPropTypes.number, textShadowColor: DeprecatedColorPropType, /** @@ -66,22 +89,24 @@ const TextStylePropTypes = { * Specifies text alignment. The value 'justify' is only supported on iOS and * fallbacks to `left` on Android. */ - textAlign: ReactPropTypes.oneOf([ + textAlign: (ReactPropTypes.oneOf([ 'auto' /*default*/, 'left', 'right', 'center', 'justify', - ]), + ]): React$PropType$Primitive< + 'auto' | 'left' | 'right' | 'center' | 'justify', + >), /** * @platform android */ - textAlignVertical: ReactPropTypes.oneOf([ + textAlignVertical: (ReactPropTypes.oneOf([ 'auto' /*default*/, 'top', 'bottom', 'center', - ]), + ]): React$PropType$Primitive<'auto' | 'top' | 'bottom' | 'center'>), /** * Set to `false` to remove extra font padding intended to make space for certain ascenders / descenders. * With some fonts, this padding can make text look slightly misaligned when centered vertically. @@ -89,35 +114,43 @@ const TextStylePropTypes = { * @platform android */ includeFontPadding: ReactPropTypes.bool, - textDecorationLine: ReactPropTypes.oneOf([ + textDecorationLine: (ReactPropTypes.oneOf([ 'none' /*default*/, 'underline', 'line-through', 'underline line-through', - ]), + ]): React$PropType$Primitive< + 'none' | 'underline' | 'line-through' | 'underline line-through', + >), /** * @platform ios */ - textDecorationStyle: ReactPropTypes.oneOf([ + textDecorationStyle: (ReactPropTypes.oneOf([ 'solid' /*default*/, 'double', 'dotted', 'dashed', - ]), + ]): React$PropType$Primitive<'solid' | 'double' | 'dotted' | 'dashed'>), /** * @platform ios */ textDecorationColor: DeprecatedColorPropType, - textTransform: ReactPropTypes.oneOf([ + textTransform: (ReactPropTypes.oneOf([ 'none' /*default*/, 'capitalize', 'uppercase', 'lowercase', - ]), + ]): React$PropType$Primitive< + 'none' | 'capitalize' | 'uppercase' | 'lowercase', + >), /** * @platform ios */ - writingDirection: ReactPropTypes.oneOf(['auto' /*default*/, 'ltr', 'rtl']), + writingDirection: (ReactPropTypes.oneOf([ + 'auto' /*default*/, + 'ltr', + 'rtl', + ]): React$PropType$Primitive<'auto' | 'ltr' | 'rtl'>), }; module.exports = TextStylePropTypes; diff --git a/Libraries/TurboModule/samples/NativeSampleTurboModule.js b/Libraries/TurboModule/samples/NativeSampleTurboModule.js index 486d555aa04516..f82a8e810878e5 100644 --- a/Libraries/TurboModule/samples/NativeSampleTurboModule.js +++ b/Libraries/TurboModule/samples/NativeSampleTurboModule.js @@ -31,4 +31,6 @@ export interface Spec extends TurboModule { +getValueWithPromise: (error: boolean) => Promise; } -export default TurboModuleRegistry.getEnforcing('SampleTurboModule'); +export default (TurboModuleRegistry.getEnforcing( + 'SampleTurboModule', +): Spec); diff --git a/Libraries/UTFSequence.js b/Libraries/UTFSequence.js index db5ff90fcf8f94..4e6c030ef20f20 100644 --- a/Libraries/UTFSequence.js +++ b/Libraries/UTFSequence.js @@ -19,7 +19,22 @@ const deepFreezeAndThrowOnMutationInDev = require('./Utilities/deepFreezeAndThro * - Source code should be limitted to ASCII. * - Less chance of typos. */ -const UTFSequence = deepFreezeAndThrowOnMutationInDev({ +const UTFSequence: $TEMPORARY$object<{| + BOM: string, + BULLET: string, + BULLET_SP: string, + MDASH: string, + MDASH_SP: string, + MIDDOT: string, + MIDDOT_KATAKANA: string, + MIDDOT_SP: string, + NBSP: string, + NDASH: string, + NDASH_SP: string, + PIZZA: string, + TRIANGLE_LEFT: string, + TRIANGLE_RIGHT: string, +|}> = deepFreezeAndThrowOnMutationInDev({ BOM: '\ufeff', // byte order mark BULLET: '\u2022', // bullet: • BULLET_SP: '\u00A0\u2022\u00A0', //  •  diff --git a/Libraries/Utilities/NativeDevLoadingView.js b/Libraries/Utilities/NativeDevLoadingView.js index 7141bb660c9a78..e672771778b8a1 100644 --- a/Libraries/Utilities/NativeDevLoadingView.js +++ b/Libraries/Utilities/NativeDevLoadingView.js @@ -22,4 +22,4 @@ export interface Spec extends TurboModule { +hide: () => void; } -export default TurboModuleRegistry.get('DevLoadingView'); +export default (TurboModuleRegistry.get('DevLoadingView'): ?Spec); diff --git a/Libraries/Utilities/NativeDeviceInfo.js b/Libraries/Utilities/NativeDeviceInfo.js index d0cf2eb88087e7..0e42dd6f25d1e5 100644 --- a/Libraries/Utilities/NativeDeviceInfo.js +++ b/Libraries/Utilities/NativeDeviceInfo.js @@ -42,7 +42,7 @@ export interface Spec extends TurboModule { |}; } -const NativeModule = TurboModuleRegistry.getEnforcing('DeviceInfo'); +const NativeModule: Spec = TurboModuleRegistry.getEnforcing('DeviceInfo'); const NativeDeviceInfo = NativeModule; diff --git a/Libraries/Utilities/NativeJSDevSupport.js b/Libraries/Utilities/NativeJSDevSupport.js index ffbf9aa65595a6..3128d3d83bd214 100644 --- a/Libraries/Utilities/NativeJSDevSupport.js +++ b/Libraries/Utilities/NativeJSDevSupport.js @@ -22,4 +22,4 @@ export interface Spec extends TurboModule { +onFailure: (errorCode: number, error: string) => void; } -export default TurboModuleRegistry.get('JSDevSupport'); +export default (TurboModuleRegistry.get('JSDevSupport'): ?Spec); diff --git a/Libraries/Utilities/NativePlatformConstantsAndroid.js b/Libraries/Utilities/NativePlatformConstantsAndroid.js index ba952618b95600..dcf276ae2ac3f4 100644 --- a/Libraries/Utilities/NativePlatformConstantsAndroid.js +++ b/Libraries/Utilities/NativePlatformConstantsAndroid.js @@ -33,4 +33,6 @@ export interface Spec extends TurboModule { +getAndroidID: () => string; } -export default TurboModuleRegistry.getEnforcing('PlatformConstants'); +export default (TurboModuleRegistry.getEnforcing( + 'PlatformConstants', +): Spec); diff --git a/Libraries/Utilities/NativePlatformConstantsIOS.js b/Libraries/Utilities/NativePlatformConstantsIOS.js index b350a6ee477b67..fd73bcffadb93b 100644 --- a/Libraries/Utilities/NativePlatformConstantsIOS.js +++ b/Libraries/Utilities/NativePlatformConstantsIOS.js @@ -29,4 +29,6 @@ export interface Spec extends TurboModule { |}; } -export default TurboModuleRegistry.getEnforcing('PlatformConstants'); +export default (TurboModuleRegistry.getEnforcing( + 'PlatformConstants', +): Spec); diff --git a/Libraries/Utilities/Platform.ios.js b/Libraries/Utilities/Platform.ios.js index 0bdb6d35a621d5..17e1caf389f5a4 100644 --- a/Libraries/Utilities/Platform.ios.js +++ b/Libraries/Utilities/Platform.ios.js @@ -20,25 +20,37 @@ export type PlatformSelectSpec = { const Platform = { __constants: null, OS: 'ios', - get Version() { + get Version(): $FlowFixMe { return this.constants.osVersion; }, - get constants() { + get constants(): {| + forceTouchAvailable: boolean, + interfaceIdiom: string, + isTesting: boolean, + osVersion: string, + reactNativeVersion: {| + major: number, + minor: number, + patch: number, + prerelease: ?number, + |}, + systemName: string, + |} { if (this.__constants == null) { this.__constants = NativePlatformConstantsIOS.getConstants(); } return this.__constants; }, - get isPad() { + get isPad(): boolean { return this.constants.interfaceIdiom === 'pad'; }, /** * Deprecated, use `isTV` instead. */ - get isTVOS() { + get isTVOS(): boolean { return Platform.isTV; }, - get isTV() { + get isTV(): boolean { return this.constants.interfaceIdiom === 'tv'; }, get isTesting(): boolean { diff --git a/Libraries/Utilities/ReactNativeTestTools.js b/Libraries/Utilities/ReactNativeTestTools.js index 6028bd94ba5026..a245134b674c95 100644 --- a/Libraries/Utilities/ReactNativeTestTools.js +++ b/Libraries/Utilities/ReactNativeTestTools.js @@ -108,12 +108,12 @@ function maximumDepthOfJSON(node: ReactTestRendererNode): number { } } -function renderAndEnforceStrictMode(element: React.Node) { +function renderAndEnforceStrictMode(element: React.Node): any { expectNoConsoleError(); return renderWithStrictMode(element); } -function renderWithStrictMode(element: React.Node) { +function renderWithStrictMode(element: React.Node): any { const WorkAroundBugWithStrictModeInTestRenderer = prps => prps.children; const StrictMode = (React: $FlowFixMe).StrictMode; return ReactTestRenderer.create( diff --git a/Libraries/Utilities/binaryToBase64.js b/Libraries/Utilities/binaryToBase64.js index 430fd46be68447..19d23d125d2249 100644 --- a/Libraries/Utilities/binaryToBase64.js +++ b/Libraries/Utilities/binaryToBase64.js @@ -12,7 +12,7 @@ const base64 = require('base64-js'); -function binaryToBase64(data: ArrayBuffer | $ArrayBufferView) { +function binaryToBase64(data: ArrayBuffer | $ArrayBufferView): any { if (data instanceof ArrayBuffer) { data = new Uint8Array(data); } diff --git a/Libraries/Utilities/differ/insetsDiffer.js b/Libraries/Utilities/differ/insetsDiffer.js index 4ebf9746260ff8..53c9d9605c4a02 100644 --- a/Libraries/Utilities/differ/insetsDiffer.js +++ b/Libraries/Utilities/differ/insetsDiffer.js @@ -24,7 +24,7 @@ const dummyInsets = { bottom: undefined, }; -const insetsDiffer = function(one: Inset, two: Inset) { +const insetsDiffer = function(one: Inset, two: Inset): boolean { one = one || dummyInsets; two = two || dummyInsets; return ( diff --git a/Libraries/Utilities/verifyComponentAttributeEquivalence.js b/Libraries/Utilities/verifyComponentAttributeEquivalence.js index a4db5ef2d252ab..98a725ab02e319 100644 --- a/Libraries/Utilities/verifyComponentAttributeEquivalence.js +++ b/Libraries/Utilities/verifyComponentAttributeEquivalence.js @@ -12,8 +12,8 @@ const getNativeComponentAttributes = require('../ReactNative/getNativeComponentAttributes'); -import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes'; import ReactNativeViewViewConfig from '../Components/View/ReactNativeViewViewConfig'; +import type {ReactNativeBaseComponentViewConfig} from '../Renderer/shims/ReactNativeTypes'; const IGNORED_KEYS = ['transform', 'hitSlop']; /** @@ -105,7 +105,7 @@ export function lefthandObjectDiff(leftObj: Object, rightObj: Object): Object { export function getConfigWithoutViewProps( viewConfig: ReactNativeBaseComponentViewConfig<>, propName: string, -) { +): $TEMPORARY$object<{||}> { if (!viewConfig[propName]) { return {}; } @@ -118,7 +118,7 @@ export function getConfigWithoutViewProps( }, {}); } -export function stringifyViewConfig(viewConfig: any) { +export function stringifyViewConfig(viewConfig: any): string { return JSON.stringify( viewConfig, (key, val) => { diff --git a/Libraries/Vibration/NativeVibration.js b/Libraries/Vibration/NativeVibration.js index 45f9fbd30a3bf4..1416925da5447e 100644 --- a/Libraries/Vibration/NativeVibration.js +++ b/Libraries/Vibration/NativeVibration.js @@ -22,4 +22,4 @@ export interface Spec extends TurboModule { +cancel: () => void; } -export default TurboModuleRegistry.getEnforcing('Vibration'); +export default (TurboModuleRegistry.getEnforcing('Vibration'): Spec); diff --git a/Libraries/WebSocket/NativeWebSocketModule.js b/Libraries/WebSocket/NativeWebSocketModule.js index 0b595b51b02861..da2c57fdabca6e 100644 --- a/Libraries/WebSocket/NativeWebSocketModule.js +++ b/Libraries/WebSocket/NativeWebSocketModule.js @@ -30,4 +30,6 @@ export interface Spec extends TurboModule { +removeListeners: (count: number) => void; } -export default TurboModuleRegistry.getEnforcing('WebSocketModule'); +export default (TurboModuleRegistry.getEnforcing( + 'WebSocketModule', +): Spec); diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index ccca07c77f2080..35f0757b4dc691 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -11,9 +11,9 @@ 'use strict'; const Blob = require('../Blob/Blob'); +const BlobManager = require('../Blob/BlobManager'); const EventTarget = require('event-target-shim'); const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter'); -const BlobManager = require('../Blob/BlobManager'); const Platform = require('../Utilities/Platform'); const WebSocketEvent = require('./WebSocketEvent'); @@ -21,9 +21,8 @@ const base64 = require('base64-js'); const binaryToBase64 = require('../Utilities/binaryToBase64'); const invariant = require('invariant'); -import NativeWebSocketModule from './NativeWebSocketModule'; - import type EventSubscription from '../vendor/emitter/EventSubscription'; +import NativeWebSocketModule from './NativeWebSocketModule'; type ArrayBufferView = | Int8Array @@ -56,11 +55,11 @@ let nextWebSocketId = 0; * See https://developer.mozilla.org/en-US/docs/Web/API/WebSocket * See https://github.com/websockets/ws */ -class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) { - static CONNECTING = CONNECTING; - static OPEN = OPEN; - static CLOSING = CLOSING; - static CLOSED = CLOSED; +class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS): any) { + static CONNECTING: number = CONNECTING; + static OPEN: number = OPEN; + static CLOSING: number = CLOSING; + static CLOSED: number = CLOSED; CONNECTING: number = CONNECTING; OPEN: number = OPEN; diff --git a/Libraries/YellowBox/UI/YellowBoxImageSource.js b/Libraries/YellowBox/UI/YellowBoxImageSource.js index 8c186beb89e502..88822ee938e3dd 100644 --- a/Libraries/YellowBox/UI/YellowBoxImageSource.js +++ b/Libraries/YellowBox/UI/YellowBoxImageSource.js @@ -29,36 +29,31 @@ const scale = PixelRatio.get(); * @license MIT */ const YellowBoxImageSource = { - alertTriangle: - scale > 2 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAB60lEQVRoge2Z3W3DIBSFj9oFPAIjZARGyAiMkBHuJh4hI2QEj5AR3Me+tQ91JALHmD8bKvmTkCr5Auc6/kzUACcnRXzuvL4GoAB8Afjeea9qXADcAfw4475c65orgBl++NeYl5ouUQiHt5tQTRJuwB6b5zLY49QVGn7I0bo+kuv60IQbuHf5CWCIqOkCgX93maia1MkRAUMo+OI+AvUPp7a50EzcUCBF6psJrUkYiZgnZJ7eId8mMeIyhpW5hyLw72LKCXsl86VqwgAKceKapW5e/nZpJnSsuHaTM7muyDq7C63JprJS69YxhNTpSlkpKeLGNHCo0EJChcSNaQA4SGiFtBMXJFSI3YVOPXFB6kMoUl9NaE0Wl4h5KQ0AOwqde+KmNrCL0EKCxJ64qQ0AlYVWSBfXZusgW6Oa0Dni2hiEv0qsoci+yUJrsoikLlKAkP11ygK54taiSOgb/O5b/DMqS+gBZeLWJlnoEX7XwQkBDPIktlEkz7hWrEmxZG4M5L9GXYTk0qxwcopKxa3VABN6cosM/C5LxTUof4ReMKHf1nRlaSnuGsGM7kfU4w8RF5Bz4aNlokLe/HQ/ngl9/Qih4L9k3h4hA1+S3odxu3Q77Hl4r1Hg75n6D01M2Difbp02Mi3ZTk5OLH4BUyEtOlDYuK0AAAAASUVORK5CYII=' - : scale > 1 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABVklEQVRYheWX4U3DMBBGH4gBMoJHyAgeoSNkAxjBG5QNOkJHCGzQDcoGZQP4gY3Oqe1cEscS4pNOqs9Jvqvv6ZrCf9fDhnutD4A3H810Br4mcW5l7hLmIdze5mZi+OJD5syeBYzC6CjyR5Ef9zI/CJMb0Im9zufC/qG2eQdchcGQuGYQ+9dJgZvl0B2xbJGrZW6IIevFXp9YVwcyB540syJfFcgSeJb0cVcDcg68XAFQCUhH+ShLBcBGIA158LQFqIB8zBRwEp9fgctcxQld/L2pZxZVAk/KkucjaDGQmoknrz35KEE2sABIRxm8tVIBaZgHb61UQOYmXk7aFgQVJ6QWPCnLAriYAVILnpTxD7yh/9EZiIEE4m+y29uMkGy1nQ6i9wYFRB5PwKdYP/v1msmnUe89gn695bG0iqjdXeMiRu9599csvGKZ0jlu0Ac/7d2rxX9Q37HW6QfX/ZguAAAAAElFTkSuQmCC' - : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvUlEQVQ4jbWT4Q3CIBCFP40DdANxg24gIzhKuwEjuIFxAkcwTtARGicoG+iPXlMCB8UfvoQc4e7ePV4A/ogWuMlqc0W7AsEo0QMNcPplugMmwMia5KwKWkNIuIkHq3wLXGQ/Sq4IC3wkLpOfmZyKeEpIEKsDYB8VN0Afkfpg30uNiycbdKcNqXEOxdBEWoEAoqta8uZ0iqqkxwGDUrSFAXAHZpOWd/+ubD5Kz335Cx1wZna4Bh54AddauVl8ARfCLO9Xq7xGAAAAAElFTkSuQmCC', - check: - scale > 2 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAqElEQVRoge3YTQ7CIBRF4bPUu/8JS6gTSaqilh95vuR+CaO2cGgYNAUzMzOzFgHlPhRaMkDAcRoltKaTeIxPtQHxGn+Q5AgJx8cQjo8hHB9DOP76Yiu/RcTmN18WLiQCjs3zBkYXVGOeLWd+xcIr5pgyEzDz7FIjISPP/FRPUM+9W4nvYVfuCSXeB3669ldEOzRFfCUSx1cicXwlEsdXIvEPKDMzM7PMbtugw3XTpNA2AAAAAElFTkSuQmCC' - : scale > 1 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAf0lEQVRYhe2UvQ2AIBQGL3EBR3AESkv3bxxFN8DmWUgwvkI+En1X0cBd+IMg+DuDyDMCs413kfMiX4EMbD3l8oCaPIU85B4mYLEF5XJscrYFPRGvb/sZ4IlocubJGdH0wj1FSG77XYT0qdUi5O+8jOjyyZQRUnkZ0UUeBMF3OQC/0VsyGlxligAAAABJRU5ErkJggg==' - : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAASElEQVQ4jWNgGJHAgIGBIYESze8ZGBjWU6L5PAMDgwBNNCdAFZJt83qoQmRDSHK2AFQhzBCy/IxsCNkBJsDAwLAfiknWPBIBAETPFeuA4fr6AAAAAElFTkSuQmCC', - chevronLeft: - scale > 2 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAgElEQVRoge3YMQ6DQBAEwRYvnf8nPAECbAnkyATsrt0lXUyPdAE6kCRJ/yXA+jopLbkhwHY6a2nNl8I1ftSA8Bm/MeQKBeNrBONrBONrBONrhMHxcPwOlMUvT32oszD8CoEj+giO6CE4oofgiB7Cj44Y86zyFoYPgOFPi5Ik6WwHji+QVIOyhqgAAAAASUVORK5CYII=' - : scale > 1 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAaUlEQVRYhe3WsQ2AMAwAwRcs5LEYg3HpYANoQKKgcEEUI/6adM5LbgySfmZsNDeACdiApdEfaQGswH6+Xd1jugc9xYQxxhjz9RhaxwxvDuul3MrAqDyjsozKKnWgXUqdsJcAZgqsTFJ5B7gjUNw0n0HHAAAAAElFTkSuQmCC' - : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAARklEQVQ4jWNgGPKAmUh1AQwMDBIMDAwPyLEkgYGB4T/UELI1J9BdcwCxmpnIMZ1YkECsK+hmCNZoZCHCgAUMDAwfoHg4AgDJuQ/bcLyV+QAAAABJRU5ErkJggg==', - chevronRight: - scale > 2 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAeElEQVRoge3YMQ6AIBQE0Ykn3fs3HEEbC6MdFp+v8xJaspNQAZIkqbcA4zwpXTJpAPvlpHTNhHtAu4jwDDCiQjBiDcGINQQj1hCMWEN4Boy3l25vL/iL0PgJBcfXCI6vERxfIzi+Rmg8Hj7wrdL+Yys0/1qUJEmzDvSAkFQ8EOdJAAAAAElFTkSuQmCC' - : scale > 1 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAZElEQVRYhe3WsQmAQAxA0Y8ulLEcw3HtdANtBNvzCJjD/5pUgQ9pApJ+Zu7YCWABDmDLzemzA+c94+MW4AkqExUY1caoVka1GibqlSm7qJJSJzPGGGMylYqBgi9sACtFYiQN7wKC6VDcJ7tlpQAAAABJRU5ErkJggg==' - : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAANUlEQVQ4jWNgGLbAgYGBIYASAwIYGBj+MzAwJFBiSMLQMISJEpMptp2mmimORgcGChPSEAIAHGENPH8gqdYAAAAASUVORK5CYII=', - loader: - scale > 2 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABXElEQVRoge2a3W3DMAyEr+0CHkGjaISOcKN4k6zQETpCR+gGzgbpQ10kcamIpKQ6avQBBPxg3pHwL2UDg/8LASxrcNdKnCwATmssrUyeWgnju/DmXs8tRP+Sh2kgAJga1rFlWj2rcMD5YqQh77QJLbzIORjyRIJQCJW5ngYo5AVlrsgkCGqbsDbAhFfxqZsSZibP0oDXQ43HQPsg82i7sBoR+VcJq2YxKcPo0IoJLRZXmYGC6ezQmQUdVqhPBVH/CNBTSMkLVlzjA8Bbocb7GoPBoADi+umZilYzbrG/JrnljOvy734iu4To/BQaDB6Rl4LciPPF9Lmjhgvi+s7w6tCIGw3WKS0P8fvWNjt0ZkGHFeq7CQXTbkZKGg2JOxrqPUZ3s6ziNdju38IjS/dLi0EQpDLX2gDQYHEX6Hx5/YcA+6H0NgAYPnCMj3x7Mxq4wTGx3Q1E578aDDR8AX0mOGD6BEN/AAAAAElFTkSuQmCC' - : scale > 1 - ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABN0lEQVRYhe2WzU3EMBCFP34KyJEjJaQDXAIlJJ24BSow2wEdhHSwJSwd7JHbcmC0mOxMnDiWDIInWbHkN29exo4n8IvRAEFGU8OAA04yulyR60Jm7msbyIZloAMGwBfI4UWrWxM08LW/weC4iOMNTog4g0awKjBG827GxBwC3996NHizAifsSrTRmlsZm23CT9adktyXSq6ZUPdxgiXnZzW8CLcLuC3lvqA/gCt5NtjlPQL7TP0Wu1HtRRu4PO3T4TKTz2kG+AG9IN6CR/Su9iojBw69egfghWgL/pGCp+JFVPUqTjWjlsuqeAo1o6rt2C8QcNiV0UxoHPMieojmz0CfMKyhl1hN84xbI3gnz5Ftp7kH3iT5LsFdDUf6pzSJ6r2glIFDbuDNhqRH4I7Pvv4EvG/QqocP2Jh/xzzX/zUAAAAASUVORK5CYII=' - : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAsklEQVQ4jaWTYRHCMAyFP7gJmIQ6oChgEpBQKXMwC3MADpAAEiphDuBHC4QuDRu8u9ylyWtem7Rgw2X7GT1wsghb4beAVzhtsfYyJgs44AoEQzBkjrMId1HkKPwyZ6oMSnxYsnk1NqT7yMo34Fzhd9meGJvs7Hh3NhqCLXDI/rT0lKsR+KOJgc9RdaRRarkZvELogYsi8HqxjUhGYE+aQg1jzketwFTZXHbbEpjB8eU7PwAbLiJz46707gAAAABJRU5ErkJggg==', + alertTriangle: ((scale > 2 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAB60lEQVRoge2Z3W3DIBSFj9oFPAIjZARGyAiMkBHuJh4hI2QEj5AR3Me+tQ91JALHmD8bKvmTkCr5Auc6/kzUACcnRXzuvL4GoAB8Afjeea9qXADcAfw4475c65orgBl++NeYl5ouUQiHt5tQTRJuwB6b5zLY49QVGn7I0bo+kuv60IQbuHf5CWCIqOkCgX93maia1MkRAUMo+OI+AvUPp7a50EzcUCBF6psJrUkYiZgnZJ7eId8mMeIyhpW5hyLw72LKCXsl86VqwgAKceKapW5e/nZpJnSsuHaTM7muyDq7C63JprJS69YxhNTpSlkpKeLGNHCo0EJChcSNaQA4SGiFtBMXJFSI3YVOPXFB6kMoUl9NaE0Wl4h5KQ0AOwqde+KmNrCL0EKCxJ64qQ0AlYVWSBfXZusgW6Oa0Dni2hiEv0qsoci+yUJrsoikLlKAkP11ygK54taiSOgb/O5b/DMqS+gBZeLWJlnoEX7XwQkBDPIktlEkz7hWrEmxZG4M5L9GXYTk0qxwcopKxa3VABN6cosM/C5LxTUof4ReMKHf1nRlaSnuGsGM7kfU4w8RF5Bz4aNlokLe/HQ/ngl9/Qih4L9k3h4hA1+S3odxu3Q77Hl4r1Hg75n6D01M2Difbp02Mi3ZTk5OLH4BUyEtOlDYuK0AAAAASUVORK5CYII=' + : scale > 1 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABVklEQVRYheWX4U3DMBBGH4gBMoJHyAgeoSNkAxjBG5QNOkJHCGzQDcoGZQP4gY3Oqe1cEscS4pNOqs9Jvqvv6ZrCf9fDhnutD4A3H810Br4mcW5l7hLmIdze5mZi+OJD5syeBYzC6CjyR5Ef9zI/CJMb0Im9zufC/qG2eQdchcGQuGYQ+9dJgZvl0B2xbJGrZW6IIevFXp9YVwcyB540syJfFcgSeJb0cVcDcg68XAFQCUhH+ShLBcBGIA158LQFqIB8zBRwEp9fgctcxQld/L2pZxZVAk/KkucjaDGQmoknrz35KEE2sABIRxm8tVIBaZgHb61UQOYmXk7aFgQVJ6QWPCnLAriYAVILnpTxD7yh/9EZiIEE4m+y29uMkGy1nQ6i9wYFRB5PwKdYP/v1msmnUe89gn695bG0iqjdXeMiRu9599csvGKZ0jlu0Ac/7d2rxX9Q37HW6QfX/ZguAAAAAElFTkSuQmCC' + : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAvUlEQVQ4jbWT4Q3CIBCFP40DdANxg24gIzhKuwEjuIFxAkcwTtARGicoG+iPXlMCB8UfvoQc4e7ePV4A/ogWuMlqc0W7AsEo0QMNcPplugMmwMia5KwKWkNIuIkHq3wLXGQ/Sq4IC3wkLpOfmZyKeEpIEKsDYB8VN0Afkfpg30uNiycbdKcNqXEOxdBEWoEAoqta8uZ0iqqkxwGDUrSFAXAHZpOWd/+ubD5Kz335Cx1wZna4Bh54AddauVl8ARfCLO9Xq7xGAAAAAElFTkSuQmCC'): string), + check: ((scale > 2 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAqElEQVRoge3YTQ7CIBRF4bPUu/8JS6gTSaqilh95vuR+CaO2cGgYNAUzMzOzFgHlPhRaMkDAcRoltKaTeIxPtQHxGn+Q5AgJx8cQjo8hHB9DOP76Yiu/RcTmN18WLiQCjs3zBkYXVGOeLWd+xcIr5pgyEzDz7FIjISPP/FRPUM+9W4nvYVfuCSXeB3669ldEOzRFfCUSx1cicXwlEsdXIvEPKDMzM7PMbtugw3XTpNA2AAAAAElFTkSuQmCC' + : scale > 1 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAf0lEQVRYhe2UvQ2AIBQGL3EBR3AESkv3bxxFN8DmWUgwvkI+En1X0cBd+IMg+DuDyDMCs413kfMiX4EMbD3l8oCaPIU85B4mYLEF5XJscrYFPRGvb/sZ4IlocubJGdH0wj1FSG77XYT0qdUi5O+8jOjyyZQRUnkZ0UUeBMF3OQC/0VsyGlxligAAAABJRU5ErkJggg==' + : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAASElEQVQ4jWNgGJHAgIGBIYESze8ZGBjWU6L5PAMDgwBNNCdAFZJt83qoQmRDSHK2AFQhzBCy/IxsCNkBJsDAwLAfiknWPBIBAETPFeuA4fr6AAAAAElFTkSuQmCC'): string), + chevronLeft: ((scale > 2 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAgElEQVRoge3YMQ6DQBAEwRYvnf8nPAECbAnkyATsrt0lXUyPdAE6kCRJ/yXA+jopLbkhwHY6a2nNl8I1ftSA8Bm/MeQKBeNrBONrBONrBONrhMHxcPwOlMUvT32oszD8CoEj+giO6CE4oofgiB7Cj44Y86zyFoYPgOFPi5Ik6WwHji+QVIOyhqgAAAAASUVORK5CYII=' + : scale > 1 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAaUlEQVRYhe3WsQ2AMAwAwRcs5LEYg3HpYANoQKKgcEEUI/6adM5LbgySfmZsNDeACdiApdEfaQGswH6+Xd1jugc9xYQxxhjz9RhaxwxvDuul3MrAqDyjsozKKnWgXUqdsJcAZgqsTFJ5B7gjUNw0n0HHAAAAAElFTkSuQmCC' + : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAARklEQVQ4jWNgGPKAmUh1AQwMDBIMDAwPyLEkgYGB4T/UELI1J9BdcwCxmpnIMZ1YkECsK+hmCNZoZCHCgAUMDAwfoHg4AgDJuQ/bcLyV+QAAAABJRU5ErkJggg=='): string), + chevronRight: ((scale > 2 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAeElEQVRoge3YMQ6AIBQE0Ykn3fs3HEEbC6MdFp+v8xJaspNQAZIkqbcA4zwpXTJpAPvlpHTNhHtAu4jwDDCiQjBiDcGINQQj1hCMWEN4Boy3l25vL/iL0PgJBcfXCI6vERxfIzi+Rmg8Hj7wrdL+Yys0/1qUJEmzDvSAkFQ8EOdJAAAAAElFTkSuQmCC' + : scale > 1 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAZElEQVRYhe3WsQmAQAxA0Y8ulLEcw3HtdANtBNvzCJjD/5pUgQ9pApJ+Zu7YCWABDmDLzemzA+c94+MW4AkqExUY1caoVka1GibqlSm7qJJSJzPGGGMylYqBgi9sACtFYiQN7wKC6VDcJ7tlpQAAAABJRU5ErkJggg==' + : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAANUlEQVQ4jWNgGLbAgYGBIYASAwIYGBj+MzAwJFBiSMLQMISJEpMptp2mmimORgcGChPSEAIAHGENPH8gqdYAAAAASUVORK5CYII='): string), + loader: ((scale > 2 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABXElEQVRoge2a3W3DMAyEr+0CHkGjaISOcKN4k6zQETpCR+gGzgbpQ10kcamIpKQ6avQBBPxg3pHwL2UDg/8LASxrcNdKnCwATmssrUyeWgnju/DmXs8tRP+Sh2kgAJga1rFlWj2rcMD5YqQh77QJLbzIORjyRIJQCJW5ngYo5AVlrsgkCGqbsDbAhFfxqZsSZibP0oDXQ43HQPsg82i7sBoR+VcJq2YxKcPo0IoJLRZXmYGC6ezQmQUdVqhPBVH/CNBTSMkLVlzjA8Bbocb7GoPBoADi+umZilYzbrG/JrnljOvy734iu4To/BQaDB6Rl4LciPPF9Lmjhgvi+s7w6tCIGw3WKS0P8fvWNjt0ZkGHFeq7CQXTbkZKGg2JOxrqPUZ3s6ziNdju38IjS/dLi0EQpDLX2gDQYHEX6Hx5/YcA+6H0NgAYPnCMj3x7Mxq4wTGx3Q1E578aDDR8AX0mOGD6BEN/AAAAAElFTkSuQmCC' + : scale > 1 + ? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABN0lEQVRYhe2WzU3EMBCFP34KyJEjJaQDXAIlJJ24BSow2wEdhHSwJSwd7JHbcmC0mOxMnDiWDIInWbHkN29exo4n8IvRAEFGU8OAA04yulyR60Jm7msbyIZloAMGwBfI4UWrWxM08LW/weC4iOMNTog4g0awKjBG827GxBwC3996NHizAifsSrTRmlsZm23CT9adktyXSq6ZUPdxgiXnZzW8CLcLuC3lvqA/gCt5NtjlPQL7TP0Wu1HtRRu4PO3T4TKTz2kG+AG9IN6CR/Su9iojBw69egfghWgL/pGCp+JFVPUqTjWjlsuqeAo1o6rt2C8QcNiV0UxoHPMieojmz0CfMKyhl1hN84xbI3gnz5Ftp7kH3iT5LsFdDUf6pzSJ6r2glIFDbuDNhqRH4I7Pvv4EvG/QqocP2Jh/xzzX/zUAAAAASUVORK5CYII=' + : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAsklEQVQ4jaWTYRHCMAyFP7gJmIQ6oChgEpBQKXMwC3MADpAAEiphDuBHC4QuDRu8u9ylyWtem7Rgw2X7GT1wsghb4beAVzhtsfYyJgs44AoEQzBkjrMId1HkKPwyZ6oMSnxYsnk1NqT7yMo34Fzhd9meGJvs7Hh3NhqCLXDI/rT0lKsR+KOJgc9RdaRRarkZvELogYsi8HqxjUhGYE+aQg1jzketwFTZXHbbEpjB8eU7PwAbLiJz46707gAAAABJRU5ErkJggg=='): string), }; module.exports = YellowBoxImageSource; diff --git a/Libraries/YellowBox/UI/YellowBoxInspector.js b/Libraries/YellowBox/UI/YellowBoxInspector.js index adcdc0d7333829..424b8ed5d13077 100644 --- a/Libraries/YellowBox/UI/YellowBoxInspector.js +++ b/Libraries/YellowBox/UI/YellowBoxInspector.js @@ -41,7 +41,7 @@ type State = {| class YellowBoxInspector extends React.Component { _symbolication: ?SymbolicationRequest; - state = { + state: State = { selectedIndex: 0, }; diff --git a/Libraries/YellowBox/UI/YellowBoxInspectorSourceMapStatus.js b/Libraries/YellowBox/UI/YellowBoxInspectorSourceMapStatus.js index 48487792293959..fbd98a9ed4aa92 100644 --- a/Libraries/YellowBox/UI/YellowBoxInspectorSourceMapStatus.js +++ b/Libraries/YellowBox/UI/YellowBoxInspectorSourceMapStatus.js @@ -34,7 +34,7 @@ type State = {| |}; class YellowBoxInspectorSourceMapStatus extends React.Component { - state = { + state: State = { animation: null, rotate: null, }; diff --git a/Libraries/YellowBox/UI/YellowBoxList.js b/Libraries/YellowBox/UI/YellowBoxList.js index 2620c35852fab7..c7fa200d1d7052 100644 --- a/Libraries/YellowBox/UI/YellowBoxList.js +++ b/Libraries/YellowBox/UI/YellowBoxList.js @@ -11,8 +11,8 @@ 'use strict'; const Dimensions = require('../../Utilities/Dimensions'); -const React = require('react'); const FlatList = require('../../Lists/FlatList'); +const React = require('react'); const SafeAreaView = require('../../Components/SafeAreaView/SafeAreaView'); const StyleSheet = require('../../StyleSheet/StyleSheet'); const View = require('../../Components/View/View'); @@ -41,7 +41,7 @@ const MAX_ITEMS = Math.floor( ); class YellowBoxList extends React.Component { - state = { + state: State = { selectedCategory: null, }; diff --git a/Libraries/YellowBox/UI/YellowBoxListRow.js b/Libraries/YellowBox/UI/YellowBoxListRow.js index f388c5083b117d..367a40e9c6835d 100644 --- a/Libraries/YellowBox/UI/YellowBoxListRow.js +++ b/Libraries/YellowBox/UI/YellowBoxListRow.js @@ -13,9 +13,9 @@ const React = require('react'); const StyleSheet = require('../../StyleSheet/StyleSheet'); const Text = require('../../Text/Text'); -const YellowBoxPressable = require('./YellowBoxPressable'); const View = require('../../Components/View/View'); const YellowBoxCategory = require('../Data/YellowBoxCategory'); +const YellowBoxPressable = require('./YellowBoxPressable'); const YellowBoxStyle = require('./YellowBoxStyle'); const YellowBoxWarning = require('../Data/YellowBoxWarning'); @@ -28,8 +28,8 @@ type Props = $ReadOnly<{| |}>; class YellowBoxListRow extends React.Component { - static GUTTER = StyleSheet.hairlineWidth; - static HEIGHT = 48; + static GUTTER: number = StyleSheet.hairlineWidth; + static HEIGHT: number = 48; shouldComponentUpdate(nextProps: Props): boolean { const prevProps = this.props; diff --git a/Libraries/YellowBox/UI/YellowBoxPressable.js b/Libraries/YellowBox/UI/YellowBoxPressable.js index 0090ca69ab37f2..ed7b688a76854d 100644 --- a/Libraries/YellowBox/UI/YellowBoxPressable.js +++ b/Libraries/YellowBox/UI/YellowBoxPressable.js @@ -16,9 +16,9 @@ const TouchableWithoutFeedback = require('../../Components/Touchable/TouchableWi const View = require('../../Components/View/View'); const YellowBoxStyle = require('./YellowBoxStyle'); -import type {PressEvent} from '../../Types/CoreEventTypes'; import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; +import type {PressEvent} from '../../Types/CoreEventTypes'; type Props = $ReadOnly<{| backgroundColor: $ReadOnly<{| @@ -36,14 +36,16 @@ type State = {| |}; class YellowBoxPressable extends React.Component { - static defaultProps = { + static defaultProps: $TEMPORARY$object<{| + backgroundColor: $TEMPORARY$object<{|default: string, pressed: string|}>, + |}> = { backgroundColor: { default: YellowBoxStyle.getBackgroundColor(0.95), pressed: YellowBoxStyle.getHighlightColor(1), }, }; - state = { + state: State = { pressed: false, }; diff --git a/Libraries/vendor/emitter/EventEmitterWithHolding.js b/Libraries/vendor/emitter/EventEmitterWithHolding.js index 945506e3c0f182..c553dde0631358 100644 --- a/Libraries/vendor/emitter/EventEmitterWithHolding.js +++ b/Libraries/vendor/emitter/EventEmitterWithHolding.js @@ -49,14 +49,14 @@ class EventEmitterWithHolding { /** * @see EventEmitter#addListener */ - addListener(eventType: string, listener: Function, context: ?Object) { + addListener(eventType: string, listener: Function, context: ?Object): any { return this._emitter.addListener(eventType, listener, context); } /** * @see EventEmitter#once */ - once(eventType: string, listener: Function, context: ?Object) { + once(eventType: string, listener: Function, context: ?Object): any { return this._emitter.once(eventType, listener, context); } @@ -115,7 +115,7 @@ class EventEmitterWithHolding { /** * @see EventEmitter#listeners */ - listeners(eventType: string) /* TODO: Annotate return type here */ { + listeners(eventType: string): any /* TODO: Annotate return type here */ { return this._emitter.listeners(eventType); } diff --git a/Libraries/vendor/emitter/EventHolder.js b/Libraries/vendor/emitter/EventHolder.js index ea68ef9d784848..54728e753904d1 100644 --- a/Libraries/vendor/emitter/EventHolder.js +++ b/Libraries/vendor/emitter/EventHolder.js @@ -42,7 +42,10 @@ class EventHolder { * }); //logs 'abc' * */ - holdEvent(eventType: string, ...args: any) { + holdEvent( + eventType: string, + ...args: any + ): $TEMPORARY$object<{|eventType: string, index: $FlowFixMeEmpty|}> { this._heldEvents[eventType] = this._heldEvents[eventType] || []; const eventsOfType = this._heldEvents[eventType]; const key = { diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js index 9645166d7b10ea..e7d7ab7f822165 100644 --- a/RNTester/js/RNTesterApp.ios.js +++ b/RNTester/js/RNTesterApp.ios.js @@ -10,7 +10,15 @@ 'use strict'; +const RNTesterActions = require('./utils/RNTesterActions'); +const RNTesterExampleContainer = require('./components/RNTesterExampleContainer'); +const RNTesterExampleList = require('./components/RNTesterExampleList'); +const RNTesterList = require('./utils/RNTesterList.ios'); +const RNTesterNavigationReducer = require('./utils/RNTesterNavigationReducer'); const React = require('react'); +const SnapshotViewIOS = require('./examples/Snapshot/SnapshotViewIOS.ios'); +const URIActionMap = require('./utils/URIActionMap'); + const { AppRegistry, AsyncStorage, @@ -23,13 +31,6 @@ const { View, YellowBox, } = require('react-native'); -const RNTesterActions = require('./utils/RNTesterActions'); -const RNTesterExampleContainer = require('./components/RNTesterExampleContainer'); -const RNTesterExampleList = require('./components/RNTesterExampleList'); -const RNTesterList = require('./utils/RNTesterList.ios'); -const RNTesterNavigationReducer = require('./utils/RNTesterNavigationReducer'); -const SnapshotViewIOS = require('./examples/Snapshot/SnapshotViewIOS.ios'); -const URIActionMap = require('./utils/URIActionMap'); import type {RNTesterExample} from './types/RNTesterTypes'; import type {RNTesterAction} from './utils/RNTesterActions'; @@ -109,7 +110,7 @@ class RNTesterApp extends React.Component { } }; - render() { + render(): React.Node | null { if (!this.state) { return null; } diff --git a/RNTester/js/components/ListExampleShared.js b/RNTester/js/components/ListExampleShared.js index 43e4f9424d9011..69e3ecc1510611 100644 --- a/RNTester/js/components/ListExampleShared.js +++ b/RNTester/js/components/ListExampleShared.js @@ -11,6 +11,7 @@ 'use strict'; const React = require('react'); + const { Animated, Image, @@ -59,7 +60,7 @@ class ItemComponent extends React.PureComponent<{ _onPress = () => { this.props.onPress(this.props.item.key); }; - render() { + render(): React.Node { const {fixedHeight, horizontal, item} = this.props; const itemHash = Math.abs(hashCode(item.title)); const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; @@ -90,7 +91,7 @@ class ItemComponent extends React.PureComponent<{ } } -const renderStackedItem = ({item}: {item: Item}) => { +const renderStackedItem = ({item}: {item: Item}): React.Node => { const itemHash = Math.abs(hashCode(item.title)); const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; return ( @@ -104,7 +105,7 @@ const renderStackedItem = ({item}: {item: Item}) => { }; class FooterComponent extends React.PureComponent<{}> { - render() { + render(): React.Node { return ( @@ -117,7 +118,7 @@ class FooterComponent extends React.PureComponent<{}> { } class HeaderComponent extends React.PureComponent<{}> { - render() { + render(): React.Node { return ( @@ -130,7 +131,7 @@ class HeaderComponent extends React.PureComponent<{}> { } class ListEmptyComponent extends React.PureComponent<{}> { - render() { + render(): React.Node { return ( The list is empty :o @@ -140,13 +141,13 @@ class ListEmptyComponent extends React.PureComponent<{}> { } class SeparatorComponent extends React.PureComponent<{}> { - render() { + render(): React.Node { return ; } } class ItemSeparatorComponent extends React.PureComponent<$FlowFixMeProps> { - render() { + render(): React.Node { const style = this.props.highlighted ? [ styles.itemSeparator, @@ -158,7 +159,7 @@ class ItemSeparatorComponent extends React.PureComponent<$FlowFixMeProps> { } class Spindicator extends React.PureComponent<$FlowFixMeProps> { - render() { + render(): React.Node { return ( { const [length, separator, header] = horizontal ? [HORIZ_WIDTH, 0, HEADER.width] : [ITEM_HEIGHT, SEPARATOR_HEIGHT, HEADER.height]; @@ -235,7 +240,10 @@ function pressItem(context: Object, key: string) { }); } -function renderSmallSwitchOption(context: Object, key: string) { +function renderSmallSwitchOption( + context: Object, + key: string, +): null | React.Node { if (Platform.isTV) { return null; } @@ -251,7 +259,7 @@ function renderSmallSwitchOption(context: Object, key: string) { ); } -function PlainInput(props: Object) { +function PlainInput(props: Object): React.Node { return ( { - state = {description: null}; + state: State = {description: null}; - render() { + render(): React.Node { const description = this.props.description ? ( {this.props.description} ) : null; diff --git a/RNTester/js/components/RNTesterButton.js b/RNTester/js/components/RNTesterButton.js index 543d52c6e0ae36..a3fa596319fab3 100644 --- a/RNTester/js/components/RNTesterButton.js +++ b/RNTester/js/components/RNTesterButton.js @@ -11,6 +11,7 @@ 'use strict'; const React = require('react'); + const {StyleSheet, Text, TouchableHighlight} = require('react-native'); import type {PressEvent} from '../../../Libraries/Types/CoreEventTypes'; @@ -21,7 +22,7 @@ type Props = $ReadOnly<{| |}>; class RNTesterButton extends React.Component { - render() { + render(): React.Node { return ( { - state = {filter: ''}; + state: State = {filter: ''}; - render() { + render(): React.Node { const filterText = this.state.filter; let filterRegex = /.*/; diff --git a/RNTester/js/components/RNTesterExampleList.js b/RNTester/js/components/RNTesterExampleList.js index c3fe40a708678e..a6cfa2c11f3b34 100644 --- a/RNTester/js/components/RNTesterExampleList.js +++ b/RNTester/js/components/RNTesterExampleList.js @@ -10,7 +10,10 @@ 'use strict'; +const RNTesterActions = require('../utils/RNTesterActions'); +const RNTesterExampleFilter = require('./RNTesterExampleFilter'); const React = require('react'); + const { Platform, SectionList, @@ -19,11 +22,9 @@ const { TouchableHighlight, View, } = require('react-native'); -const RNTesterActions = require('../utils/RNTesterActions'); -const RNTesterExampleFilter = require('./RNTesterExampleFilter'); -import type {RNTesterExample} from '../types/RNTesterTypes'; import type {ViewStyleProp} from '../../../Libraries/StyleSheet/StyleSheet'; +import type {RNTesterExample} from '../types/RNTesterTypes'; type Props = { onNavigate: Function, @@ -69,7 +70,7 @@ const renderSectionHeader = ({section}) => ( ); class RNTesterExampleList extends React.Component { - render() { + render(): React.Node { const filter = ({example, filterRegex}) => filterRegex.test(example.module.title) && (!Platform.isTV || example.supportsTVOS); diff --git a/RNTester/js/components/RNTesterPage.js b/RNTester/js/components/RNTesterPage.js index 6b1b0fe1db6112..51481cdc8cb53f 100644 --- a/RNTester/js/components/RNTesterPage.js +++ b/RNTester/js/components/RNTesterPage.js @@ -10,10 +10,10 @@ 'use strict'; +const RNTesterTitle = require('./RNTesterTitle'); const React = require('react'); -const {ScrollView, StyleSheet, View} = require('react-native'); -const RNTesterTitle = require('./RNTesterTitle'); +const {ScrollView, StyleSheet, View} = require('react-native'); type Props = $ReadOnly<{| children?: React.Node, @@ -23,7 +23,7 @@ type Props = $ReadOnly<{| |}>; class RNTesterPage extends React.Component { - render() { + render(): React.Node { let ContentWrapper; let wrapperProps = {}; if (this.props.noScroll) { diff --git a/RNTester/js/components/RNTesterTitle.js b/RNTester/js/components/RNTesterTitle.js index a50ac5066c395e..df418fdbadcc8d 100644 --- a/RNTester/js/components/RNTesterTitle.js +++ b/RNTester/js/components/RNTesterTitle.js @@ -11,10 +11,11 @@ 'use strict'; const React = require('react'); + const {StyleSheet, Text, View} = require('react-native'); class RNTesterTitle extends React.Component<$FlowFixMeProps> { - render() { + render(): React.Node { return ( {this.props.title} diff --git a/RNTester/js/components/TextInlineView.js b/RNTester/js/components/TextInlineView.js index d69f5b10507833..e5fcc68aaeac4c 100644 --- a/RNTester/js/components/TextInlineView.js +++ b/RNTester/js/components/TextInlineView.js @@ -11,9 +11,10 @@ 'use strict'; const React = require('react'); + const {Image, Text, TouchableHighlight, View} = require('react-native'); -function Basic() { +function Basic(): React.Node { return ( This text contains an inline blue view{' '} @@ -24,7 +25,7 @@ function Basic() { ); } -function ClippedByText() { +function ClippedByText(): React.Node { return ( {/* @@ -92,11 +93,11 @@ type ChangeSizeState = {| |}; class ChangeImageSize extends React.Component<*, ChangeSizeState> { - state = { + state: ChangeSizeState = { width: 50, }; - render() { + render(): React.Node { return ( { } class ChangeViewSize extends React.Component<*, ChangeSizeState> { - state = { + state: ChangeSizeState = { width: 50, }; - render() { + render(): React.Node { return ( { } class ChangeInnerViewSize extends React.Component<*, ChangeSizeState> { - state = { + state: ChangeSizeState = { width: 50, }; - render() { + render(): React.Node { return ( { - state = { + state: $TEMPORARY$object<{| + alignment: $TEMPORARY$string<'left'>, + fontSize: number, + language: $TEMPORARY$string<'english'>, + textMetrics: Array, + |}> = { textMetrics: [], language: 'english', alignment: 'left', fontSize: 50, }; - render() { + render(): React.Node { const PANGRAMS = { arabic: 'صِف خَلقَ خَودِ كَمِثلِ الشَمسِ إِذ بَزَغَت — يَحظى الضَجيعُ بِها نَجلاءَ مِعطارِ', diff --git a/RNTester/js/examples/ActivityIndicator/ActivityIndicatorExample.js b/RNTester/js/examples/ActivityIndicator/ActivityIndicatorExample.js index ca25a457aa8f18..b18ceb92934ed9 100644 --- a/RNTester/js/examples/ActivityIndicator/ActivityIndicatorExample.js +++ b/RNTester/js/examples/ActivityIndicator/ActivityIndicatorExample.js @@ -9,9 +9,9 @@ */ 'use strict'; - -import React, {Component} from 'react'; +import type {Node} from 'React'; import {ActivityIndicator, StyleSheet, View} from 'react-native'; +import React, {Component} from 'react'; type State = {|animating: boolean|}; type Props = $ReadOnly<{||}>; @@ -77,7 +77,7 @@ exports.description = 'Animated loading indicators.'; exports.examples = [ { title: 'Default (small, white)', - render() { + render(): Node { return ( @@ -99,7 +99,7 @@ exports.examples = [ }, { title: 'Custom colors', - render() { + render(): Node { return ( @@ -112,7 +112,7 @@ exports.examples = [ }, { title: 'Large', - render() { + render(): Node { return ( @@ -137,13 +137,13 @@ exports.examples = [ }, { title: 'Start/stop', - render() { + render(): Node { return ; }, }, { title: 'Custom size', - render() { + render(): Node { return ( ; }, }, diff --git a/RNTester/js/examples/Alert/AlertIOSExample.js b/RNTester/js/examples/Alert/AlertIOSExample.js index 45c735523acb26..18bcaa4655da5a 100644 --- a/RNTester/js/examples/Alert/AlertIOSExample.js +++ b/RNTester/js/examples/Alert/AlertIOSExample.js @@ -11,6 +11,8 @@ 'use strict'; const React = require('react'); + +const {SimpleAlertExampleBlock} = require('./AlertExample'); const { StyleSheet, View, @@ -19,8 +21,6 @@ const { Alert, } = require('react-native'); -const {SimpleAlertExampleBlock} = require('./AlertExample'); - type Props = $ReadOnly<{||}>; type State = {|promptValue: ?string|}; @@ -157,7 +157,7 @@ exports.description = 'iOS alerts and action sheets'; exports.examples = [ { title: 'Alerts', - render() { + render(): React.Node { return ; }, }, @@ -169,7 +169,7 @@ exports.examples = [ }, { title: 'Prompt Types', - render() { + render(): React.Node { return ( { constructor(props) { super(props); @@ -113,13 +112,12 @@ exports.examples = [ }, { title: 'Transform Bounce', - description: - 'One `Animated.Value` is driven by a ' + + description: ('One `Animated.Value` is driven by a ' + 'spring with custom constants and mapped to an ' + 'ordered set of transforms. Each transform has ' + 'an interpolation to convert the value into the ' + - 'right range and units.', - render: function() { + 'right range and units.': string), + render: function(): React.Node { this.anim = this.anim || new Animated.Value(0); return ( @@ -181,10 +179,9 @@ exports.examples = [ }, { title: 'Composite Animations with Easing', - description: - 'Sequence, parallel, delay, and ' + - 'stagger with different easing functions.', - render: function() { + description: ('Sequence, parallel, delay, and ' + + 'stagger with different easing functions.': string), + render: function(): React.Node { this.anims = this.anims || [1, 2, 3].map(() => new Animated.Value(0)); return ( @@ -279,7 +276,7 @@ exports.examples = [ { title: 'Rotating Images', description: 'Simple Animated.Image rotation.', - render: function() { + render: function(): React.Node { this.anim = this.anim || new Animated.Value(0); return ( @@ -340,10 +337,11 @@ exports.examples = [ }, { title: 'Continuous Interactions', - description: - 'Gesture events, chaining, 2D ' + + description: ('Gesture events, chaining, 2D ' + 'values, interrupting and transitioning ' + - 'animations, etc.', - render: () => Checkout the Gratuitous Animation App!, + 'animations, etc.': string), + render: (): React.Node => ( + Checkout the Gratuitous Animation App! + ), }, ]; diff --git a/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExChained.js b/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExChained.js index f8128a629ec9c4..fb720bfe539673 100644 --- a/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExChained.js +++ b/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExChained.js @@ -11,6 +11,7 @@ 'use strict'; const React = require('react'); + const {Animated, PanResponder, StyleSheet, View} = require('react-native'); class AnExChained extends React.Component { @@ -68,7 +69,7 @@ class AnExChained extends React.Component { }); } - render() { + render(): React.Node { return ( {this.state.stickers.map((_, i) => { diff --git a/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExScroll.js b/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExScroll.js index 0bd79b9635f78d..87afc77f24b2ad 100644 --- a/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExScroll.js +++ b/RNTester/js/examples/Animated/AnimatedGratuitousApp/AnExScroll.js @@ -11,6 +11,7 @@ 'use strict'; const React = require('react'); + const { Animated, Image, @@ -23,7 +24,7 @@ const { class AnExScroll extends React.Component<$FlowFixMeProps, any> { state: any = {scrollX: new Animated.Value(0)}; - render() { + render(): React.Node { const width = this.props.panelWidth; return ( diff --git a/RNTester/js/examples/AppState/AppStateExample.js b/RNTester/js/examples/AppState/AppStateExample.js index 24ecbcc27450de..9e7f17eefc1201 100644 --- a/RNTester/js/examples/AppState/AppStateExample.js +++ b/RNTester/js/examples/AppState/AppStateExample.js @@ -11,6 +11,7 @@ 'use strict'; const React = require('react'); + const {AppState, Text, View} = require('react-native'); class AppStateSubscription extends React.Component< @@ -75,7 +76,7 @@ exports.examples = [ { title: 'AppState.currentState', description: 'Can be null on app initialization', - render() { + render(): React.Node { return {AppState.currentState}; }, }, diff --git a/RNTester/js/examples/Button/ButtonExample.js b/RNTester/js/examples/Button/ButtonExample.js index 2dfad341b0c327..36e8a4eb4a626a 100644 --- a/RNTester/js/examples/Button/ButtonExample.js +++ b/RNTester/js/examples/Button/ButtonExample.js @@ -11,6 +11,7 @@ 'use strict'; const React = require('react'); + const {Alert, Button, View, StyleSheet} = require('react-native'); function onButtonPress(buttonName) { @@ -25,11 +26,10 @@ exports.description = 'Simple React Native button component.'; exports.examples = [ { title: 'Simple Button', - description: - 'The title and onPress handler are required. It is ' + + description: ('The title and onPress handler are required. It is ' + 'recommended to set accessibilityLabel to help make your app usable by ' + - 'everyone.', - render: function() { + 'everyone.': string), + render: function(): React.Node { return (