From 363818ea204e662ba417b2f403d3d73ad39dbb03 Mon Sep 17 00:00:00 2001 From: Panos Vekris Date: Mon, 21 Oct 2024 19:26:02 -0700 Subject: [PATCH] pre-suppress errors before enabling experimental.object_freeze_fix (#47141) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47141 D64152004 fixed a soundness hole in Flow's checking of frozen object types (e.g. try-Flow https://fburl.com/rmct2mf6). This diff suppresses Flow errors that appear when this fix is enabled (`experimental.object_freeze_fix` flag is set). For most of these cases the result of `Object.freeze()` is assigned to some variable typed as a mutable type. The variable is then passed to a context where its fields can be written to. Thus changing the annotation type to a readonly version would only cause more errors downstream. So, instead, these assignments are suppressed so that the choice of using Object.freeze can be revisited. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D64699992 fbshipit-source-id: 48e4376d4ed3dbda21d32cabe512e6457384994f --- .../Libraries/Components/ScrollView/ScrollViewContext.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewContext.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewContext.js index 4c194ad5494..e08fda8bc65 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewContext.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewContext.js @@ -18,5 +18,7 @@ if (__DEV__) { } export default ScrollViewContext; +// $FlowFixMe[incompatible-type] frozen objects are readonly export const HORIZONTAL: Value = Object.freeze({horizontal: true}); +// $FlowFixMe[incompatible-type] frozen objects are readonly export const VERTICAL: Value = Object.freeze({horizontal: false});