From 67e12a19cb236fbe0809fbbc9e516b37a5848a6a Mon Sep 17 00:00:00 2001 From: George Zahariev Date: Mon, 11 Jul 2022 11:33:24 -0700 Subject: [PATCH] Suppress errors ahead of launch Summary: Ahead of enabling the `exact_empty_objects` option, suppress errors so that actually enabling the option is easier. We can do this without enabling the option by codemoding `{}` to `{...null}` in files that have errors. Process: 1) Get list of files with errors when enabling the option 2) Codemod `{}` to `{...null}` in those files 3) Suppress resulting errors 4) Land diff with `drop-conflicts` flag 5) Announce and enable option (with many fewer files to edit) 6) Codemod all `{...null}` to `{}` drop-conflicts We are working on making the empty object literal `{}` have the type `{}` - i.e. exact empty object - rather than being unsealed. More info in these posts: https://fb.workplace.com/groups/flowlang/posts/903386663600331, https://fb.workplace.com/groups/floweng/posts/8626146484100557 Reviewed By: pieterv Differential Revision: D37731004 fbshipit-source-id: a9305859ba4e8adbdb8ae8feff3ec8a2f07ed236 --- Libraries/Animated/AnimatedImplementation.js | 9 +++++-- Libraries/Animated/AnimatedMock.js | 5 +++- Libraries/Animated/NativeAnimatedHelper.js | 24 +++++++++++++------ .../AnimatedGratuitousApp/AnExBobble.js | 12 ++++++++-- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Libraries/Animated/AnimatedImplementation.js b/Libraries/Animated/AnimatedImplementation.js index 32707208a6ef71..f1c6896be5481d 100644 --- a/Libraries/Animated/AnimatedImplementation.js +++ b/Libraries/Animated/AnimatedImplementation.js @@ -369,7 +369,9 @@ const parallel = function ( ): CompositeAnimation { let doneCount = 0; // Make sure we only call stop() at most once for each animation - const hasEnded = {}; + const hasEnded = { + ...null, + }; const stopTogether = !(config && config.stopTogether === false); const result = { @@ -460,7 +462,10 @@ type LoopAnimationConfig = { const loop = function ( animation: CompositeAnimation, - {iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {}, + // $FlowFixMe[prop-missing] + {iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = { + ...null, + }, ): CompositeAnimation { let isFinished = false; let iterationsSoFar = 0; diff --git a/Libraries/Animated/AnimatedMock.js b/Libraries/Animated/AnimatedMock.js index 6efb74fd003261..636a090d99d1cf 100644 --- a/Libraries/Animated/AnimatedMock.js +++ b/Libraries/Animated/AnimatedMock.js @@ -160,7 +160,10 @@ type LoopAnimationConfig = { const loop = function ( animation: CompositeAnimation, - {iterations = -1}: LoopAnimationConfig = {}, + // $FlowFixMe[prop-missing] + {iterations = -1}: LoopAnimationConfig = { + ...null, + }, ): CompositeAnimation { return emptyAnimation; }; diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index 629f13ab0bb68b..9184b12e7a8bc8 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -48,8 +48,12 @@ const useSingleOpBatching = ReactNativeFeatureFlags.animatedShouldUseSingleOp(); let flushQueueTimeout = null; -const eventListenerGetValueCallbacks = {}; -const eventListenerAnimationFinishedCallbacks = {}; +const eventListenerGetValueCallbacks = { + ...null, +}; +const eventListenerAnimationFinishedCallbacks = { + ...null, +}; let globalEventEmitterGetValueListener: ?EventSubscription = null; let globalEventEmitterAnimationFinishedListener: ?EventSubscription = null; @@ -78,11 +82,17 @@ 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). - acc[functionName] = i + 1; - return acc; - }, {}); + 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, + }, + ); })(): $FlowFixMe) : NativeAnimatedModule; diff --git a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExBobble.js b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExBobble.js index 3b68d395cba89a..264c57805764c3 100644 --- a/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExBobble.js +++ b/packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExBobble.js @@ -30,7 +30,10 @@ const BOBBLE_SPOTS = [...Array(NUM_BOBBLES)].map((_, i) => { class AnExBobble extends React.Component { constructor(props: Object) { super(props); - this.state = {}; + this.state = { + ...null, + }; + // $FlowFixMe[prop-missing] this.state.bobbles = BOBBLE_SPOTS.map((_, i) => { return new Animated.ValueXY(); }); @@ -98,7 +101,12 @@ class AnExBobble extends React.Component { {this.state.bobbles.map((_, i) => { const j = this.state.bobbles.length - i - 1; // reverse so lead on top - const handlers = j > 0 ? {} : this.state.bobbleResponder.panHandlers; + const handlers = + j > 0 + ? { + ...null, + } + : this.state.bobbleResponder.panHandlers; return (