Skip to content

Commit f392ba6

Browse files
gkzfacebook-github-bot
authored andcommitted
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
1 parent 1e91445 commit f392ba6

File tree

10 files changed

+19
-41
lines changed

10 files changed

+19
-41
lines changed

Libraries/Animated/AnimatedImplementation.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ const parallel = function (
369369
): CompositeAnimation {
370370
let doneCount = 0;
371371
// Make sure we only call stop() at most once for each animation
372-
const hasEnded = {
373-
...null,
374-
};
372+
const hasEnded = {};
375373
const stopTogether = !(config && config.stopTogether === false);
376374

377375
const result = {
@@ -463,9 +461,7 @@ type LoopAnimationConfig = {
463461
const loop = function (
464462
animation: CompositeAnimation,
465463
// $FlowFixMe[prop-missing]
466-
{iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {
467-
...null,
468-
},
464+
{iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {},
469465
): CompositeAnimation {
470466
let isFinished = false;
471467
let iterationsSoFar = 0;

Libraries/Animated/AnimatedMock.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ type LoopAnimationConfig = {
161161
const loop = function (
162162
animation: CompositeAnimation,
163163
// $FlowFixMe[prop-missing]
164-
{iterations = -1}: LoopAnimationConfig = {
165-
...null,
166-
},
164+
{iterations = -1}: LoopAnimationConfig = {},
167165
): CompositeAnimation {
168166
return emptyAnimation;
169167
};

Libraries/Animated/NativeAnimatedHelper.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ const useSingleOpBatching =
4848
ReactNativeFeatureFlags.animatedShouldUseSingleOp();
4949
let flushQueueTimeout = null;
5050

51-
const eventListenerGetValueCallbacks = {
52-
...null,
53-
};
54-
const eventListenerAnimationFinishedCallbacks = {
55-
...null,
56-
};
51+
const eventListenerGetValueCallbacks = {};
52+
const eventListenerAnimationFinishedCallbacks = {};
5753
let globalEventEmitterGetValueListener: ?EventSubscription = null;
5854
let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null;
5955

@@ -82,17 +78,12 @@ const nativeOps: ?typeof NativeAnimatedModule = useSingleOpBatching
8278
'addListener', // 20
8379
'removeListener', // 21
8480
];
85-
return apis.reduce(
86-
(acc, functionName, i) => {
87-
// 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).
88-
// $FlowFixMe[prop-missing]
89-
acc[functionName] = i + 1;
90-
return acc;
91-
},
92-
{
93-
...null,
94-
},
95-
);
81+
return apis.reduce((acc, functionName, i) => {
82+
// 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).
83+
// $FlowFixMe[prop-missing]
84+
acc[functionName] = i + 1;
85+
return acc;
86+
}, {});
9687
})(): $FlowFixMe)
9788
: NativeAnimatedModule;
9889

Libraries/Components/TextInput/TextInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ function InternalTextInput(props: Props): React.Node {
986986
// that the update should be ignored and we should stick with the value
987987
// that we have in JS.
988988
useLayoutEffect(() => {
989-
const nativeUpdate: {text?: string, selection?: Selection} = {...null};
989+
const nativeUpdate: {text?: string, selection?: Selection} = {};
990990

991991
if (lastNativeText !== props.value && typeof props.value === 'string') {
992992
nativeUpdate.text = props.value;

Libraries/Core/setUpPerformance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'use strict';
1212

1313
if (!global.performance) {
14-
global.performance = ({...null}: {now?: () => number});
14+
global.performance = ({}: {now?: () => number});
1515
}
1616

1717
/**

Libraries/Utilities/__tests__/stringifySafe-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('stringifySafe', () => {
3333
});
3434

3535
it('stringifySafe stringifies circular objects with toString', () => {
36-
const arg: {arg?: {...}} = {...null};
36+
const arg: {arg?: {...}} = {};
3737
arg.arg = arg;
3838
const result = stringifySafe(arg);
3939
expect(result).toEqual('[object Object]');

Libraries/WebSocket/WebSocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class WebSocket extends (EventTarget(...WEBSOCKET_EVENTS): any) {
101101
protocols = [protocols];
102102
}
103103

104-
const {headers = {}, ...unrecognized} = options || {...null};
104+
const {headers = {}, ...unrecognized} = options || {};
105105

106106
// Preserve deprecated backwards compatibility for the 'origin' option
107107
// $FlowFixMe[prop-missing]

packages/rn-tester/js/components/RNTesterPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class RNTesterPage extends React.Component<Props> {
2727
automaticallyAdjustContentInsets?: boolean,
2828
keyboardShouldPersistTaps?: string,
2929
keyboardDismissMode?: string,
30-
} = {...null};
30+
} = {};
3131
if (this.props.noScroll) {
3232
ContentWrapper = ((View: any): React.ComponentType<any>);
3333
} else {

packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExBobble.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ const BOBBLE_SPOTS = [...Array(NUM_BOBBLES)].map((_, i) => {
3030
class AnExBobble extends React.Component<Object, any> {
3131
constructor(props: Object) {
3232
super(props);
33-
this.state = {
34-
...null,
35-
};
33+
this.state = {};
3634
// $FlowFixMe[prop-missing]
3735
this.state.bobbles = BOBBLE_SPOTS.map((_, i) => {
3836
return new Animated.ValueXY();
@@ -101,12 +99,7 @@ class AnExBobble extends React.Component<Object, any> {
10199
<View style={styles.bobbleContainer}>
102100
{this.state.bobbles.map((_, i) => {
103101
const j = this.state.bobbles.length - i - 1; // reverse so lead on top
104-
const handlers =
105-
j > 0
106-
? {
107-
...null,
108-
}
109-
: this.state.bobbleResponder.panHandlers;
102+
const handlers = j > 0 ? {} : this.state.bobbleResponder.panHandlers;
110103
return (
111104
<Animated.Image
112105
{...handlers}

packages/rn-tester/js/examples/Crash/CrashExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exports.examples = [
2626
<Button
2727
title="JS crash"
2828
onPress={() => {
29-
const a = {...null};
29+
const a = {};
3030
// $FlowIgnore[prop-missing]
3131
// $FlowIgnore[incompatible-use]
3232
const b = a.w.q; // js crash here

0 commit comments

Comments
 (0)