Skip to content

Commit

Permalink
Exact-by-default codemod for react-native-github
Browse files Browse the repository at this point in the history
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
  • Loading branch information
gkz authored and facebook-github-bot committed Nov 21, 2019
1 parent 1ad0862 commit 8553e1a
Show file tree
Hide file tree
Showing 205 changed files with 879 additions and 379 deletions.
2 changes: 1 addition & 1 deletion IntegrationTests/AccessibilityManagerTest.js
Expand Up @@ -18,7 +18,7 @@ const {TestModule} = ReactNative.NativeModules;
import NativeAccessibilityManager from 'react-native/Libraries/Components/AccessibilityInfo/NativeAccessibilityManager';
import invariant from 'invariant';

class AccessibilityManagerTest extends React.Component<{}> {
class AccessibilityManagerTest extends React.Component<{...}> {
componentDidMount() {
invariant(
NativeAccessibilityManager,
Expand Down
9 changes: 7 additions & 2 deletions IntegrationTests/AppEventsTest.js
Expand Up @@ -19,14 +19,19 @@ const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer')

const TEST_PAYLOAD = {foo: 'bar'};

type AppEvent = {data: Object, ts: number};
type AppEvent = {
data: Object,
ts: number,
...
};
type State = {
sent: 'none' | AppEvent,
received: 'none' | AppEvent,
elapsed?: string,
...
};

class AppEventsTest extends React.Component<{}, State> {
class AppEventsTest extends React.Component<{...}, State> {
state: State = {sent: 'none', received: 'none'};

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/AsyncStorageTest.js
Expand Up @@ -171,7 +171,7 @@ function testOptimizedMultiGet() {
});
}

class AsyncStorageTest extends React.Component<{}, $FlowFixMeState> {
class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> {
state: any | {|done: boolean, messages: string|} = {
messages: 'Initializing...',
done: false,
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/GlobalEvalWithSourceUrlTest.js
Expand Up @@ -17,7 +17,7 @@ const {View} = ReactNative;

const {TestModule} = ReactNative.NativeModules;

class GlobalEvalWithSourceUrlTest extends React.Component<{}> {
class GlobalEvalWithSourceUrlTest extends React.Component<{...}> {
componentDidMount() {
if (typeof global.globalEvalWithSourceUrl !== 'function') {
throw new Error(
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/ImageCachePolicyTest.js
Expand Up @@ -27,12 +27,13 @@ const {TestModule} = ReactNative.NativeModules;

const TESTS = ['only-if-cached', 'default', 'reload', 'force-cache'];

type Props = {};
type Props = {...};
type State = {
'only-if-cached'?: boolean,
default?: boolean,
reload?: boolean,
'force-cache'?: boolean,
...
};

class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/ImageSnapshotTest.js
Expand Up @@ -15,7 +15,7 @@ const ReactNative = require('react-native');
const {Image} = ReactNative;
const {TestModule} = ReactNative.NativeModules;

class ImageSnapshotTest extends React.Component<{}> {
class ImageSnapshotTest extends React.Component<{...}> {
componentDidMount() {
if (!TestModule.verifySnapshot) {
throw new Error('TestModule.verifySnapshot not defined.');
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/IntegrationTestsApp.js
Expand Up @@ -51,7 +51,7 @@ require('./LoggingTestModule');

type Test = any;

class IntegrationTestsApp extends React.Component<{}, $FlowFixMeState> {
class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
state = {
test: (null: ?Test),
};
Expand Down
1 change: 1 addition & 0 deletions IntegrationTests/LayoutEventsTest.js
Expand Up @@ -38,6 +38,7 @@ type State = {
viewLayout?: Layout,
viewStyle?: ViewStyleProp,
containerStyle?: ViewStyleProp,
...
};

class LayoutEventsTest extends React.Component<Props, State> {
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/PromiseTest.js
Expand Up @@ -15,7 +15,7 @@ const ReactNative = require('react-native');
const {View} = ReactNative;
const {TestModule} = ReactNative.NativeModules;

class PromiseTest extends React.Component<{}> {
class PromiseTest extends React.Component<{...}> {
shouldResolve: boolean = false;
shouldReject: boolean = false;
shouldSucceedAsync: boolean = false;
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/SimpleSnapshotTest.js
Expand Up @@ -18,7 +18,7 @@ const requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
const {StyleSheet, View} = ReactNative;
const {TestModule} = ReactNative.NativeModules;

class SimpleSnapshotTest extends React.Component<{}> {
class SimpleSnapshotTest extends React.Component<{...}> {
componentDidMount() {
if (!TestModule.verifySnapshot) {
throw new Error('TestModule.verifySnapshot not defined.');
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/SizeFlexibilityUpdateTest.js
Expand Up @@ -54,7 +54,8 @@ class SizeFlexibilityUpdateTest extends React.Component<Props> {
rootViewDidChangeIntrinsicSize: (intrinsicSize: {
height: number,
width: number,
}) => void = (intrinsicSize: {width: number, height: 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);
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/SyncMethodTest.js
Expand Up @@ -16,7 +16,7 @@ const {View} = ReactNative;

const {TestModule, RNTesterTestModule} = ReactNative.NativeModules;

class SyncMethodTest extends React.Component<{}> {
class SyncMethodTest extends React.Component<{...}> {
componentDidMount() {
if (
RNTesterTestModule.echoString('test string value') !== 'test string value'
Expand Down
3 changes: 2 additions & 1 deletion IntegrationTests/WebSocketTest.js
Expand Up @@ -28,9 +28,10 @@ type State = {
lastMessage: ?string | ?ArrayBuffer,
testMessage: string,
testExpectedResponse: string,
...
};

class WebSocketTest extends React.Component<{}, State> {
class WebSocketTest extends React.Component<{...}, State> {
state: State = {
url: DEFAULT_WS_URL,
fetchStatus: null,
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Alert/Alert.js
Expand Up @@ -26,11 +26,13 @@ export type Buttons = Array<{
text?: string,
onPress?: ?Function,
style?: AlertButtonStyle,
...
}>;

type Options = {
cancelable?: ?boolean,
onDismiss?: ?() => void,
...
};

/**
Expand Down
7 changes: 3 additions & 4 deletions Libraries/Animated/src/AnimatedEvent.js
Expand Up @@ -18,10 +18,11 @@ const invariant = require('invariant');

const {shouldUseNativeDriver} = require('./NativeAnimatedHelper');

export type Mapping = {[key: string]: Mapping} | AnimatedValue;
export type Mapping = {[key: string]: Mapping, ...} | AnimatedValue;
export type EventConfig = {
listener?: ?Function,
useNativeDriver: boolean,
...
};

function attachNativeEvent(
Expand Down Expand Up @@ -87,9 +88,7 @@ class AnimatedEvent {
_argMapping: Array<?Mapping>;
_listeners: Array<Function> = [];
_callListeners: Function;
_attachedEvent: ?{
detach: () => void,
};
_attachedEvent: ?{detach: () => void, ...};
__isNative: boolean;

constructor(argMapping: Array<?Mapping>, config: EventConfig) {
Expand Down
6 changes: 5 additions & 1 deletion Libraries/Animated/src/AnimatedImplementation.js
Expand Up @@ -46,6 +46,7 @@ export type CompositeAnimation = {
reset: () => void,
_startNativeLoop: (iterations?: number) => void,
_isUsingNativeDriver: () => boolean,
...
};

const add = function(
Expand Down Expand Up @@ -341,7 +342,9 @@ const sequence = function(
};

type ParallelConfig = {
stopTogether?: boolean, // If one is stopped, stop all. default: true
// If one is stopped, stop all. default: true
stopTogether?: boolean,
...
};
const parallel = function(
animations: Array<CompositeAnimation>,
Expand Down Expand Up @@ -435,6 +438,7 @@ const stagger = function(
type LoopAnimationConfig = {
iterations: number,
resetBeforeIteration?: boolean,
...
};

const loop = function(
Expand Down
11 changes: 7 additions & 4 deletions Libraries/Animated/src/AnimatedMock.js
Expand Up @@ -37,6 +37,7 @@ export type CompositeAnimation = {
reset: () => void,
_startNativeLoop: (iterations?: number) => void,
_isUsingNativeDriver: () => boolean,
...
};

const emptyAnimation = {
Expand Down Expand Up @@ -90,9 +91,7 @@ const sequence = function(
return emptyAnimation;
};

type ParallelConfig = {
stopTogether?: boolean,
};
type ParallelConfig = {stopTogether?: boolean, ...};
const parallel = function(
animations: Array<CompositeAnimation>,
config?: ?ParallelConfig,
Expand All @@ -111,7 +110,11 @@ const stagger = function(
return emptyAnimation;
};

type LoopAnimationConfig = {iterations: number, resetBeforeIteration?: boolean};
type LoopAnimationConfig = {
iterations: number,
resetBeforeIteration?: boolean,
...
};

const loop = function(
animation: CompositeAnimation,
Expand Down
16 changes: 13 additions & 3 deletions Libraries/Animated/src/NativeAnimatedHelper.js
Expand Up @@ -217,8 +217,18 @@ function addWhitelistedInterpolationParam(param: string): void {

function validateTransform(
configs: Array<
| {type: 'animated', property: string, nodeTag: ?number}
| {type: 'static', property: string, value: number | string},
| {
type: 'animated',
property: string,
nodeTag: ?number,
...
}
| {
type: 'static',
property: string,
value: number | string,
...
},
>,
): void {
configs.forEach(config => {
Expand All @@ -232,7 +242,7 @@ function validateTransform(
});
}
function validateStyles(styles: {[key: string]: ?number}): void {
function validateStyles(styles: {[key: string]: ?number, ...}): void {
for (const key in styles) {
if (!STYLES_WHITELIST.hasOwnProperty(key)) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Animated/src/NativeAnimatedModule.js
Expand Up @@ -13,7 +13,7 @@
import type {TurboModule} from '../../TurboModule/RCTExport';
import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry';

type EndResult = {finished: boolean};
type EndResult = {finished: boolean, ...};
type EndCallback = (result: EndResult) => void;

export type EventMapping = {|
Expand Down
1 change: 1 addition & 0 deletions Libraries/Animated/src/SpringConfig.js
Expand Up @@ -13,6 +13,7 @@
type SpringConfigType = {
stiffness: number,
damping: number,
...
};

function stiffnessFromOrigamiValue(oValue) {
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Animated/src/animations/Animation.js
Expand Up @@ -14,14 +14,15 @@ const NativeAnimatedHelper = require('../NativeAnimatedHelper');

import type AnimatedValue from '../nodes/AnimatedValue';

export type EndResult = {finished: boolean};
export type EndResult = {finished: boolean, ...};
export type EndCallback = (result: EndResult) => void;

export type AnimationConfig = {
isInteraction?: boolean,
useNativeDriver: boolean,
onComplete?: ?EndCallback,
iterations?: number,
...
};

// Important note: start() and stop() will only be called at most once.
Expand Down
10 changes: 9 additions & 1 deletion Libraries/Animated/src/animations/DecayAnimation.js
Expand Up @@ -18,13 +18,21 @@ import type AnimatedValue from '../nodes/AnimatedValue';
import type {AnimationConfig, EndCallback} from './Animation';

export type DecayAnimationConfig = AnimationConfig & {
velocity: number | {x: number, y: number},
velocity:
| number
| {
x: number,
y: number,
...
},
deceleration?: number,
...
};

export type DecayAnimationConfigSingle = AnimationConfig & {
velocity: number,
deceleration?: number,
...
};

class DecayAnimation extends Animation {
Expand Down
20 changes: 18 additions & 2 deletions Libraries/Animated/src/animations/SpringAnimation.js
Expand Up @@ -22,11 +22,25 @@ const {shouldUseNativeDriver} = require('../NativeAnimatedHelper');
import type {AnimationConfig, EndCallback} from './Animation';

export type SpringAnimationConfig = AnimationConfig & {
toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY,
toValue:
| number
| AnimatedValue
| {
x: number,
y: number,
...
}
| AnimatedValueXY,
overshootClamping?: boolean,
restDisplacementThreshold?: number,
restSpeedThreshold?: number,
velocity?: number | {x: number, y: number},
velocity?:
| number
| {
x: number,
y: number,
...
},
bounciness?: number,
speed?: number,
tension?: number,
Expand All @@ -35,6 +49,7 @@ export type SpringAnimationConfig = AnimationConfig & {
damping?: number,
mass?: number,
delay?: number,
...
};

export type SpringAnimationConfigSingle = AnimationConfig & {
Expand All @@ -51,6 +66,7 @@ export type SpringAnimationConfigSingle = AnimationConfig & {
damping?: number,
mass?: number,
delay?: number,
...
};

class SpringAnimation extends Animation {
Expand Down
12 changes: 11 additions & 1 deletion Libraries/Animated/src/animations/TimingAnimation.js
Expand Up @@ -19,17 +19,27 @@ const {shouldUseNativeDriver} = require('../NativeAnimatedHelper');
import type {AnimationConfig, EndCallback} from './Animation';

export type TimingAnimationConfig = AnimationConfig & {
toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY,
toValue:
| number
| AnimatedValue
| {
x: number,
y: number,
...
}
| AnimatedValueXY,
easing?: (value: number) => number,
duration?: number,
delay?: number,
...
};

export type TimingAnimationConfigSingle = AnimationConfig & {
toValue: number | AnimatedValue,
easing?: (value: number) => number,
duration?: number,
delay?: number,
...
};

let _easeInOut;
Expand Down

0 comments on commit 8553e1a

Please sign in to comment.