Skip to content

Commit 7f5df1d

Browse files
panagosg7meta-codesync[bot]
authored andcommitted
Enable assertion functions in React Native GitHub (#59090)
Summary: Pull Request resolved: #59090 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] ___ landed-with-radar-review Differential Revision: D125271821 fbshipit-source-id: 23672b08893644b38fa00dc378eb72c435912604
1 parent 6671827 commit 7f5df1d

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎.flowconfig‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ packages/react-native-codegen/e2e/__test_fixtures__/modules/NativeEnumTurboModul
1616
**/*.windows.js
1717

1818
**/node_modules/resolve/test/resolver/malformed_package_json/package.json
19+
**/node_modules/invariant/**
1920

2021
; Checked-in build output
2122
packages/debugger-frontend/dist/**
@@ -52,6 +53,9 @@ experimental.multi_platform=true
5253
experimental.multi_platform.extensions=.ios
5354
experimental.multi_platform.extensions=.android
5455

56+
experimental.assertion_functions=true
57+
experimental.disable_invariant_special_casing=true
58+
5559
munge_underscores=true
5660

5761
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/packages/react-native/index.js'

‎flow-typed/npm/invariant_v2.x.x.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
declare module 'invariant' {
12+
declare module.exports: (
13+
condition: unknown,
14+
format?: string,
15+
...args: Array<unknown>
16+
) => asserts condition;
17+
}
18+
19+
declare module 'invariant/invariant' {
20+
import typeof Invariant from 'invariant';
21+
22+
declare module.exports: Invariant;
23+
}

0 commit comments

Comments
 (0)