Skip to content

Fix Flow types that use void for a missing value (#2263) - #2263

Merged
meta-codesync[bot] merged 1 commit into
mainfrom
export-D133660832
Nov 22, 2026
Merged

meta-codesync[bot] merged 1 commit into
mainfrom
export-D133660832

Conversation

@SamChou19815

@SamChou19815 SamChou19815 commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary:

Under Flow's experimental.ts_void, void is TypeScript's void, which flows only into void, any and unknown, so a value typed void can't be passed where an optional value is expected. This updates Metro's Flow types for projects that check Metro's sources with that option: RAM bundle encoding parameters become optional parameters, the bundle output's save() returns Promise<void>, two test helpers admit void, and the two errors whose only fix needs the undefined type, which this repository's Flow config doesn't enable, are suppressed.

Without that option, void and undefined are the same type, so nothing changes.

Changelog: [Internal]

Differential Revision: D133660832

@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 Nov 21, 2026
@meta-codesync

meta-codesync Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@SamChou19815 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D133660832.

@SamChou19815 SamChou19815 added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported labels Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Metro review: Looks good

Risk: low · Commit: 4e68f47 · 5 commands run

The PR changes only Flow types so that Metro type-checks under experimental.ts_void. Parameters typed void | T become optional, the bundle output's save() returns Promise<void>, two test helper types now admit void, and the two call sites that pass a void value where undefined is expected get suppression comments. I found no problems. Every changed encoding parameter is the last parameter of a module-private function, save() returns nothing, and Flow, lint, the affected tests and the API snapshots all pass on the head commit.

No findings.

Verified
  • ✅ yarn typecheck — No errors on the head commit.
  • ✅ yarn flow check --include-warnings (searched the output for Transformer.js and index.flow.js) — No warnings at either of the two new suppression comments, even though this repo's .flowconfig doesn't enable ts_void.
  • ✅ yarn eslint <7 changed files>
  • ✅ yarn jest --no-watchman packages/metro/src/DeltaBundler/__tests__/resolver-test.js packages/metro/src/shared/output — 2 suites, 267 tests passed.
  • ✅ yarn verify-api-snapshots — 18 public API snapshots verified. No exported types changed.

Not run: I didn't type-check with experimental.ts_void turned on, because this repo's Flow config doesn't use it, so the claim that the suppressed errors only appear under that option is untested. I ran no benchmarks: the change touches only types and comments and generates no different runtime code. Windows doesn't matter for this change.

Automated review by Claude. Advisory only: it never approves or blocks, and a maintainer makes the call.

Summary:

Under Flow's `experimental.ts_void`, `void` is TypeScript's `void`, which flows only into `void`, `any` and `unknown`, so a value typed `void` can't be passed where an optional value is expected. This updates Metro's Flow types for projects that check Metro's sources with that option: RAM bundle `encoding` parameters become optional parameters, the bundle output's `save()` returns `Promise<void>`, two test helpers admit `void`, and the two errors whose only fix needs the `undefined` type, which this repository's Flow config doesn't enable, are suppressed.

Without that option, `void` and `undefined` are the same type, so nothing changes.

Changelog: [Internal]

Differential Revision: D133660832
@meta-codesync meta-codesync Bot changed the title Fix Flow types that use void for a missing value Fix Flow types that use void for a missing value (#2263) Nov 22, 2026
@meta-codesync
meta-codesync Bot merged commit 579e62e into main Nov 22, 2026
18 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