[*] Chore: always use T[] syntax instead of Array<T> in TypeScript and Flow#8675
Open
etrepum wants to merge 3 commits into
Open
[*] Chore: always use T[] syntax instead of Array<T> in TypeScript and Flow#8675etrepum wants to merge 3 commits into
etrepum wants to merge 3 commits into
Conversation
…d Flow
- Enable @typescript-eslint/array-type ({default: 'array'}) in
eslint.config.mjs and apply its autofix across all TypeScript sources
(Array<T> -> T[], ReadonlyArray<T> -> readonly T[])
- Add scripts/flow-array-type-codemod.mjs, a hermes-parser based codemod
that rewrites Array<T> to T[] in the hand-maintained
packages/*/flow/*.js.flow files and the Flow libdefs in libdefs/*.js
(--check reports offenders without writing), and run it
https://claude.ai/code/session_018YjGZxfHEhFsSfsbEYaSV8
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
potatowagon
reviewed
Jun 11, 2026
potatowagon
left a comment
Contributor
There was a problem hiding this comment.
Reviewed by Navi (Tater Thoughts Bobblehead) on behalf of @potatowagon.
LGTM ✅
Summary: Pure mechanical style enforcement — converts all Array<T> syntax to T[] across 133 files (TypeScript source, Flow type defs, and test files). Adds @typescript-eslint/array-type ESLint rule to enforce going forward, and includes a new scripts/flow-array-type-codemod.mjs to maintain the same convention in Flow files.
What I checked:
- Semantic equivalence:
Array<T>andT[]are semantically identical in both TypeScript and Flow. The transformations are purely syntactic — no runtime behavior changes. - Complex type handling: Verified that union/intersection types in array positions are correctly parenthesized (e.g.
Array<string | Token>→(string | Token)[],Array<typeof undefined | boolean | null | string>→(typeof undefined | boolean | null | string)[]). The codemod script has aPOSTFIX_SAFE_TYPESset to distinguish cases needing parens. - ReadonlyArray handling:
ReadonlyArray<T>correctly becomesreadonly T[](verified inuseLexicalCommandsLog.tsandvitest.setup.mts). - Flow files: Flow libdefs and
.js.flowfiles are also updated consistently. The codemod script uses hermes-parser for Flow parsing, which is the correct tool. - No API surface changes: Only type syntax is changing — no renamed exports, no changed function signatures, no behavioral changes. Safe for www consumers.
- CI: ALL checks pass — unit tests (Node 22.x + 24.x), browser tests (all platforms), e2e tests (full matrix including collab), integrity checks, CLA, and Vercel deployments.
- Edge cases in codemod: The script uses innermost-first fixed-point approach for nested
Array<Array<T>>cases, and re-parses after each pass to ensure offset correctness. Robust implementation.
www compat: ✅ No impact. No removed/renamed exports, no changed public API types at runtime. The Flow type defs maintain the same semantic meaning.
Ready to approve.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Test plan
Type-only change