Skip to content

Commit 77914ed

Browse files
panagosg7meta-codesync[bot]
authored andcommitted
Upgrade Flow to 0.337.0 (#5432)
Summary: Pull Request resolved: #5432 Upgrade Flow to 0.337.0 across Metro, React Native, and Relay. Flow 0.337 no longer special-cases `invariant`, so give `invariant` an `asserts` signature in the Metro and Relay Flow configs, matching React Native. Add targeted suppressions for the remaining new Flow 0.337 errors. X-link: react/react-native#59326 X-link: react/metro#2086 [changelog](https://github.com/facebook/flow/blob/main/Changelog.md) Changelog: [Internal] Reviewed By: SamChou19815 Differential Revision: D126755886
1 parent b417593 commit 77914ed

5 files changed

Lines changed: 33 additions & 6 deletions

File tree

‎.flowconfig‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ compiler/**
44
**/*/node_modules/**
55
packages/relay-e2e-test/**
66
**/node_modules/resolve/test/resolver/malformed_package_json/package.json
7+
**/node_modules/invariant/**
78

89
[options]
910
builtin_lib=core-only
@@ -13,6 +14,7 @@ module.system=haste
1314
module.system.haste.paths.excludes=.*/__tests__/.*
1415
module.system.haste.paths.excludes=.*/__mocks__/.*
1516
module.system.haste.paths.includes=<PROJECT_ROOT>/node_modules/fbjs/lib/.*
17+
module.system.haste.paths.excludes=<PROJECT_ROOT>/node_modules/fbjs/lib/invariant.*
1618

1719
munge_underscores=true
1820
; https://fburl.com/code/h2jnts20 - to match internval value
@@ -32,4 +34,4 @@ untyped-import
3234
untyped-type-import
3335

3436
[version]
35-
^0.336.0
37+
^0.337.0

‎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+
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"eslint-plugin-relay": "1.8.3",
6565
"eslint-plugin-relay-internal": "link:./packages/eslint-plugin-relay-internal",
6666
"fbjs": "^3.0.2",
67-
"flow-bin": "^0.336.0",
67+
"flow-bin": "^0.337.0",
6868
"flow-eslint": "0.336.0",
6969
"flow-parser": "0.336.0",
7070
"graphql": "15.3.0",

‎packages/relay-runtime/store/__tests__/RelayModernEnvironment-ExecuteWithUndeclaredUnusedArgument-test.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ describe('query with undeclared, unused fragment argument', () => {
138138
(snapshot.data as $FlowFixMe).node,
139139
);
140140
invariant(fragmentSelector != null, 'Expected a singular selector.');
141+
// $FlowFixMe[incompatible-type] Flow 0.337
141142
const fragmentSnapshot = environment.lookup(fragmentSelector);
142143
expect(fragmentSnapshot.isMissingData).toBe(false);
143144
expect(fragmentSnapshot.data).toEqual({
@@ -157,6 +158,7 @@ describe('query with undeclared, unused fragment argument', () => {
157158
fragmentSnapshot.data as $FlowFixMe,
158159
);
159160
invariant(innerSelector != null, 'Expected a singular selector.');
161+
// $FlowFixMe[incompatible-type] Flow 0.337
160162
const innerSnapshot = environment.lookup(innerSelector);
161163
expect(innerSnapshot.isMissingData).toBe(false);
162164
expect(innerSnapshot.data).toEqual({

‎yarn.lock‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,10 +3699,10 @@ flatted@^3.1.0:
36993699
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.6.tgz#022e9218c637f9f3fc9c35ab9c9193f05add60b2"
37003700
integrity sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==
37013701

3702-
flow-bin@^0.336.0:
3703-
version "0.336.0"
3704-
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.336.0.tgz#ac946f9cdf134b83ab4f7a98a0de34324f6b94f4"
3705-
integrity sha512-I5sPg/GISpXH4W14eGWgiIsrDKY0uvvvXjlEDOI2t0pguEwbMgpnaYzMMMBoHZcYYtNJIF/0eGsbPnN7uP2zOQ==
3702+
flow-bin@^0.337.0:
3703+
version "0.337.0"
3704+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.337.0.tgz#419252403924033308160351e95f723bcf42597c"
3705+
integrity sha512-rpr+WvY30RdXPNHbioErMM8tLKUOKJ8/neXPpsDYRBp9z7WDkl4bpTBUMZiqh9ozfdcDWEACBTXwIl94h/ZA0A==
37063706

37073707
flow-eslint@0.336.0:
37083708
version "0.336.0"

0 commit comments

Comments
 (0)