Skip to content

fix(flow): a Flow library's declarations are globals of the files Flow reads - #3165

Merged
colbymchenry merged 1 commit into
mainfrom
claude/fx-flow-library-globals
Nov 1, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/fx-flow-library-globals

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

stream: ReadableStream in react's Flow files stopped linking to declare class ReadableStream in flow-typed/environments/streams.js. PR #2736 keeps a
type a module doesn't import to its own file, a declaration file or a declare global block, and a Flow library is none of them: a .js script of declare
statements. The types a Flow library declares were lost on every file. PR #2736
never shipped.

Fix: a .js script with a top-level declare statement is a Flow library, its
declare module.exports no CommonJS export, and its top level global to the
JavaScript files Flow reads, which see it as they see a .d.ts. A TypeScript
file doesn't: its ReadableStream is TypeScript's own. A library's own bare
type names are held to the same rule, and a top-level call declare(...) is no
statement.

Validation

  • Tests: fail on main, pass here, on this head.
  • No extraction change, so nothing to compare between engines.
  • A/B against 4499d007:
Repo Added Removed Moved
react, where it was found 207 3 0
metro 174 5 0
excalidraw, vscode-be, express, taxonomy 0 0 0
Controls: flask, gin 0 0 0

All grouped by name and read. react: ReadableStream 82, ConsoleTask 54, AsyncLocalStorage 36, WritableStream 20, ExtensionRuntimePort 13. metro: Buffer 125, Jest's types, http$IncomingMessage, ws$WebSocket. Removed, all false: a Flow library's Function linked to an enum member and to a declare module block's alias, and HTMLElement to a property.

  • Index CPU: the six together, median of 3 interleaved: react 131.0 to 132.4 s (+1.1%, rounds spread 112 to 145 s; wall -6.4%), vscode-be 43.8 to 44.0 s (+0.6%), django 68.0 to 66.4 s (-2.3%). Level within noise.
  • Suite: the six PRs of this set ran as one stack, 97cd3800, all six on 4499d007: 853 files passed, 6 skipped; 10,610 tests passed, 2 expected fail, 87 skipped, 0 failed; 4 workers, Vitest 4.1.11, CODEGRAPH_KERNEL_EXPECT=1. This PR's own test files pass on this head.

🤖 Generated with Claude Code

…w reads

`stream: ReadableStream` in react's Flow files stopped linking to `declare
class ReadableStream` in `flow-typed/environments/streams.js`. PR #2736 keeps a
type a module doesn't import to its own file, a declaration file or a `declare
global` block, and a Flow library is none of them: a `.js` script of `declare`
statements. The types a Flow library declares were lost on every file. PR #2736
never shipped.

Fix: a `.js` script with a top-level `declare` statement is a Flow library, its
`declare module.exports` no CommonJS export, and its top level global to the
JavaScript files Flow reads, which see it as they see a `.d.ts`. A TypeScript
file doesn't: its `ReadableStream` is TypeScript's own. A library's own bare
type names are held to the same rule, and a top-level call `declare(...)` is no
statement.

Validation: tests fail on main and pass here. A/B against 4499d00: react 207 added, 3 false removed (a
`Function` to an enum member, an `HTMLElement` to a property); metro 174 added
(`Buffer`, `http$IncomingMessage`, Jest's types), 5 false removed; excalidraw,
vscode-be, express, taxonomy, flask, gin identical. Index CPU: level (see the PR).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@colbymchenry
colbymchenry merged commit 6473f60 into main Nov 1, 2026
@colbymchenry
colbymchenry deleted the claude/fx-flow-library-globals branch November 1, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant