Skip to content

Remove 3 sketchy-null suppressions (constant-folding-plugin, getRamBundleInfo, symbolicate) - #2090

Merged
meta-codesync[bot] merged 1 commit into
react:mainfrom
jcperez-ch:export-D127164728
Oct 23, 2026
Merged

meta-codesync[bot] merged 1 commit into
react:mainfrom
jcperez-ch:export-D127164728

Conversation

@jcperez-ch

Copy link
Copy Markdown
Contributor

Summary:
Replaces three sketchy-null suppressions in Metro with explicit checks that keep the exact runtime behavior.

  • metro-transform-plugins/src/constant-folding-plugin.js: removes $FlowFixMe[sketchy-null-mixed] on path.replaceWith(result.value ? node.consequent : node.alternate). result.value is unknown, so the test becomes Boolean(result.value). That is the same truthiness test the ternary did implicitly, for every value. It is read into const valueIsTruthy first because Metro's ESLint no-extra-boolean-cast flags Boolean() directly in a ternary test. The existing $FlowFixMe[incompatible-type] on the call is unchanged.
  • metro/src/DeltaBundler/Serializers/getRamBundleInfo.js: removes $FlowFixMe[sketchy-null-bool] on preloadedModules || {}. preloadedModules is typed ?Readonly<{[path: string]: true}> | false. An object is always truthy, so || falls back exactly for null, undefined and false; the new check is preloadedModules != null && preloadedModules !== false ? preloadedModules : {}.
  • metro-symbolicate/src/symbolicate.js (readAll): removes // flowlint-next-line sketchy-null-string:off on while ((chunk = stream.read())). read() returns ?(string | Buffer); a Buffer is always truthy, so the loop stopped exactly on null, undefined or ''. The loop now reads before the check and again at the end of the body, with while (chunk != null && chunk !== ''). read() is still called once per iteration and the loop stops on the same values. The read is split out because Flow does not refine a value assigned inside a loop condition.

No || was rewritten to ??. No new suppressions, casts, any, comments, or tests. metro-symbolicate has no checked-in symbolicate.js.flow; the .js.flow copies only exist under node_modules and are generated by the build.

Changelog: [Internal]

Differential Revision: D127164728

…ndleInfo, symbolicate)

Summary:
Replaces three sketchy-null suppressions in Metro with explicit checks that keep the exact runtime behavior.

- `metro-transform-plugins/src/constant-folding-plugin.js`: removes `$FlowFixMe[sketchy-null-mixed]` on `path.replaceWith(result.value ? node.consequent : node.alternate)`. `result.value` is `unknown`, so the test becomes `Boolean(result.value)`. That is the same truthiness test the ternary did implicitly, for every value. It is read into `const valueIsTruthy` first because Metro's ESLint `no-extra-boolean-cast` flags `Boolean()` directly in a ternary test. The existing `$FlowFixMe[incompatible-type]` on the call is unchanged.
- `metro/src/DeltaBundler/Serializers/getRamBundleInfo.js`: removes `$FlowFixMe[sketchy-null-bool]` on `preloadedModules || {}`. `preloadedModules` is typed `?Readonly<{[path: string]: true}> | false`. An object is always truthy, so `||` falls back exactly for `null`, `undefined` and `false`; the new check is `preloadedModules != null && preloadedModules !== false ? preloadedModules : {}`.
- `metro-symbolicate/src/symbolicate.js` (`readAll`): removes `// flowlint-next-line sketchy-null-string:off` on `while ((chunk = stream.read()))`. `read()` returns `?(string | Buffer)`; a `Buffer` is always truthy, so the loop stopped exactly on `null`, `undefined` or `''`. The loop now reads before the check and again at the end of the body, with `while (chunk != null && chunk !== '')`. `read()` is still called once per iteration and the loop stops on the same values. The read is split out because Flow does not refine a value assigned inside a loop condition.

No `||` was rewritten to `??`. No new suppressions, casts, `any`, comments, or tests. `metro-symbolicate` has no checked-in `symbolicate.js.flow`; the `.js.flow` copies only exist under `node_modules` and are generated by the build.

Changelog: [Internal]

Differential Revision: D127164728
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 23, 2026
@meta-codesync

meta-codesync Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@jcperez-ch has exported this pull request. If you are a Meta employee, you can view the originating Diff in D127164728.

@meta-codesync
meta-codesync Bot merged commit 8558522 into react:main Oct 23, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants