Skip to content

Commit

Permalink
Suppress errors ahead of launch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gkz authored and facebook-github-bot committed Jul 11, 2022
1 parent bb46046 commit 67e12a1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
9 changes: 7 additions & 2 deletions Libraries/Animated/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion Libraries/Animated/AnimatedMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ type LoopAnimationConfig = {

const loop = function (
animation: CompositeAnimation,
{iterations = -1}: LoopAnimationConfig = {},
// $FlowFixMe[prop-missing]
{iterations = -1}: LoopAnimationConfig = {
...null,
},
): CompositeAnimation {
return emptyAnimation;
};
Expand Down
24 changes: 17 additions & 7 deletions Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
12 changes: 10 additions & 2 deletions packages/rn-tester/js/examples/AnimatedGratuitousApp/AnExBobble.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const BOBBLE_SPOTS = [...Array(NUM_BOBBLES)].map((_, i) => {
class AnExBobble extends React.Component<Object, any> {
constructor(props: Object) {
super(props);
this.state = {};
this.state = {
...null,
};
// $FlowFixMe[prop-missing]
this.state.bobbles = BOBBLE_SPOTS.map((_, i) => {
return new Animated.ValueXY();
});
Expand Down Expand Up @@ -98,7 +101,12 @@ 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 ? {} : this.state.bobbleResponder.panHandlers;
const handlers =
j > 0
? {
...null,
}
: this.state.bobbleResponder.panHandlers;
return (
<Animated.Image
{...handlers}
Expand Down

0 comments on commit 67e12a1

Please sign in to comment.