From 6a8595d45425420208f502b2be7cd51c079798f7 Mon Sep 17 00:00:00 2001 From: Panos Vekris Date: Wed, 14 Oct 2026 12:19:50 -0700 Subject: [PATCH] Enable assertion functions in React Native GitHub Summary: Enable `experimental.assertion_functions` and `experimental.disable_invariant_special_casing` in `react-native-github/.github.flowconfig`. Add local libdefs for `invariant` and `invariant/invariant` returning `asserts condition`, and ignore `node_modules/invariant/**` so the package's own types cannot override them. Changelog: [Internal] Differential Revision: D125271821 --- .flowconfig | 4 ++++ flow-typed/npm/invariant_v2.x.x.js | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 flow-typed/npm/invariant_v2.x.x.js diff --git a/.flowconfig b/.flowconfig index f8075b2b4bd1..0cd86610c277 100644 --- a/.flowconfig +++ b/.flowconfig @@ -16,6 +16,7 @@ packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeEnumTurboModul **/*.windows.js **/node_modules/resolve/test/resolver/malformed_package_json/package.json +**/node_modules/invariant/** ; Checked-in build output packages/debugger-frontend/dist/** @@ -52,6 +53,9 @@ experimental.multi_platform=true experimental.multi_platform.extensions=.ios experimental.multi_platform.extensions=.android +experimental.assertion_functions=true +experimental.disable_invariant_special_casing=true + munge_underscores=true module.name_mapper='^react-native$' -> '/packages/react-native/index.js' diff --git a/flow-typed/npm/invariant_v2.x.x.js b/flow-typed/npm/invariant_v2.x.x.js new file mode 100644 index 000000000000..74cb0815afc9 --- /dev/null +++ b/flow-typed/npm/invariant_v2.x.x.js @@ -0,0 +1,23 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +declare module 'invariant' { + declare module.exports: ( + condition: unknown, + format?: string, + ...args: Array + ) => asserts condition; +} + +declare module 'invariant/invariant' { + import typeof Invariant from 'invariant'; + + declare module.exports: Invariant; +}