mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Codemod {...null} to {} in xplat/js
Summary: Now that [exact_empty_objects has been enabled](https://fb.workplace.com/groups/flowlang/posts/1092665251339137), we can codemod `{...null}` to `{}` - they are now equivalent. 1) Run my one-off jscodeshift codemod 2) `scripts/flow/tool update-suppressions .` (as some suppressions move around due to the change) drop-conflicts Reviewed By: bradzacher Differential Revision: D37834078 fbshipit-source-id: 6bf4913910e5597e5dd9d5161cd35deece6a7581
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1e91445aaa
commit
f392ba6725
@@ -369,9 +369,7 @@ const parallel = function (
|
||||
): CompositeAnimation {
|
||||
let doneCount = 0;
|
||||
// Make sure we only call stop() at most once for each animation
|
||||
const hasEnded = {
|
||||
...null,
|
||||
};
|
||||
const hasEnded = {};
|
||||
const stopTogether = !(config && config.stopTogether === false);
|
||||
|
||||
const result = {
|
||||
@@ -463,9 +461,7 @@ type LoopAnimationConfig = {
|
||||
const loop = function (
|
||||
animation: CompositeAnimation,
|
||||
// $FlowFixMe[prop-missing]
|
||||
{iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {
|
||||
...null,
|
||||
},
|
||||
{iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {},
|
||||
): CompositeAnimation {
|
||||
let isFinished = false;
|
||||
let iterationsSoFar = 0;
|
||||
|
||||
@@ -161,9 +161,7 @@ type LoopAnimationConfig = {
|
||||
const loop = function (
|
||||
animation: CompositeAnimation,
|
||||
// $FlowFixMe[prop-missing]
|
||||
{iterations = -1}: LoopAnimationConfig = {
|
||||
...null,
|
||||
},
|
||||
{iterations = -1}: LoopAnimationConfig = {},
|
||||
): CompositeAnimation {
|
||||
return emptyAnimation;
|
||||
};
|
||||
|
||||
@@ -48,12 +48,8 @@ const useSingleOpBatching =
|
||||
ReactNativeFeatureFlags.animatedShouldUseSingleOp();
|
||||
let flushQueueTimeout = null;
|
||||
|
||||
const eventListenerGetValueCallbacks = {
|
||||
...null,
|
||||
};
|
||||
const eventListenerAnimationFinishedCallbacks = {
|
||||
...null,
|
||||
};
|
||||
const eventListenerGetValueCallbacks = {};
|
||||
const eventListenerAnimationFinishedCallbacks = {};
|
||||
let globalEventEmitterGetValueListener: ?EventSubscription = null;
|
||||
let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
|
||||
|
||||
@@ -82,17 +78,12 @@ const nativeOps: ?typeof NativeAnimatedModule = useSingleOpBatching
|
||||
'addListener', // 20
|
||||
'removeListener', // 21
|
||||
];
|
||||
return apis.reduce(
|
||||
(acc, functionName, i) => {
|
||||
// These indices need to be kept in sync with the indices in native (see NativeAnimatedModule in Java, or the equivalent for any other native platform).
|
||||
// $FlowFixMe[prop-missing]
|
||||
acc[functionName] = i + 1;
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
...null,
|
||||
},
|
||||
);
|
||||
return apis.reduce((acc, functionName, i) => {
|
||||
// These indices need to be kept in sync with the indices in native (see NativeAnimatedModule in Java, or the equivalent for any other native platform).
|
||||
// $FlowFixMe[prop-missing]
|
||||
acc[functionName] = i + 1;
|
||||
return acc;
|
||||
}, {});
|
||||
})(): $FlowFixMe)
|
||||
: NativeAnimatedModule;
|
||||
|
||||
|
||||
@@ -986,7 +986,7 @@ function InternalTextInput(props: Props): React.Node {
|
||||
// that the update should be ignored and we should stick with the value
|
||||
// that we have in JS.
|
||||
useLayoutEffect(() => {
|
||||
const nativeUpdate: {text?: string, selection?: Selection} = {...null};
|
||||
const nativeUpdate: {text?: string, selection?: Selection} = {};
|
||||
|
||||
if (lastNativeText !== props.value && typeof props.value === 'string') {
|
||||
nativeUpdate.text = props.value;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
'use strict';
|
||||
|
||||
if (!global.performance) {
|
||||
global.performance = ({...null}: {now?: () => number});
|
||||
global.performance = ({}: {now?: () => number});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('stringifySafe', () => {
|
||||
});
|
||||
|
||||
it('stringifySafe stringifies circular objects with toString', () => {
|
||||
const arg: {arg?: {...}} = {...null};
|
||||
const arg: {arg?: {...}} = {};
|
||||
arg.arg = arg;
|
||||
const result = stringifySafe(arg);
|
||||
expect(result).toEqual('[object Object]');
|
||||
|
||||
@@ -101,7 +101,7 @@ class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS): any) {
|
||||
protocols = [protocols];
|
||||
}
|
||||
|
||||
const {headers = {}, ...unrecognized} = options || {...null};
|
||||
const {headers = {}, ...unrecognized} = options || {};
|
||||
|
||||
// Preserve deprecated backwards compatibility for the 'origin' option
|
||||
// $FlowFixMe[prop-missing]
|
||||
|
||||
@@ -27,7 +27,7 @@ class RNTesterPage extends React.Component<Props> {
|
||||
automaticallyAdjustContentInsets?: boolean,
|
||||
keyboardShouldPersistTaps?: string,
|
||||
keyboardDismissMode?: string,
|
||||
} = {...null};
|
||||
} = {};
|
||||
if (this.props.noScroll) {
|
||||
ContentWrapper = ((View: any): React.ComponentType<any>);
|
||||
} else {
|
||||
|
||||
@@ -30,9 +30,7 @@ const BOBBLE_SPOTS = [...Array(NUM_BOBBLES)].map((_, i) => {
|
||||
class AnExBobble extends React.Component<Object, any> {
|
||||
constructor(props: Object) {
|
||||
super(props);
|
||||
this.state = {
|
||||
...null,
|
||||
};
|
||||
this.state = {};
|
||||
// $FlowFixMe[prop-missing]
|
||||
this.state.bobbles = BOBBLE_SPOTS.map((_, i) => {
|
||||
return new Animated.ValueXY();
|
||||
@@ -101,12 +99,7 @@ class AnExBobble extends React.Component<Object, any> {
|
||||
<View style={styles.bobbleContainer}>
|
||||
{this.state.bobbles.map((_, i) => {
|
||||
const j = this.state.bobbles.length - i - 1; // reverse so lead on top
|
||||
const handlers =
|
||||
j > 0
|
||||
? {
|
||||
...null,
|
||||
}
|
||||
: this.state.bobbleResponder.panHandlers;
|
||||
const handlers = j > 0 ? {} : this.state.bobbleResponder.panHandlers;
|
||||
return (
|
||||
<Animated.Image
|
||||
{...handlers}
|
||||
|
||||
@@ -26,7 +26,7 @@ exports.examples = [
|
||||
<Button
|
||||
title="JS crash"
|
||||
onPress={() => {
|
||||
const a = {...null};
|
||||
const a = {};
|
||||
// $FlowIgnore[prop-missing]
|
||||
// $FlowIgnore[incompatible-use]
|
||||
const b = a.w.q; // js crash here
|
||||
|
||||
Reference in New Issue
Block a user