Skip to content

[*] Chore: always use T[] syntax instead of Array<T> in TypeScript and Flow#8675

Open
etrepum wants to merge 3 commits into
facebook:mainfrom
etrepum:claude/kind-bohr-yytwvj
Open

[*] Chore: always use T[] syntax instead of Array<T> in TypeScript and Flow#8675
etrepum wants to merge 3 commits into
facebook:mainfrom
etrepum:claude/kind-bohr-yytwvj

Conversation

@etrepum

@etrepum etrepum commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Enable @typescript-eslint/array-type ({default: 'array'}) in eslint.config.mjs and apply its autofix across all TypeScript sources (Array -> T[], ReadonlyArray -> readonly T[])
  • Add scripts/flow-array-type-codemod.mjs, a hermes-parser based codemod that rewrites Array 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

Test plan

Type-only change

…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
@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 Jun 11, 2026
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Jun 11, 2026 5:39am
lexical-playground Ready Ready Preview, Comment Jun 11, 2026 5:39am

Request Review

@potatowagon potatowagon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> and T[] 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 a POSTFIX_SAFE_TYPES set to distinguish cases needing parens.
  • ReadonlyArray handling: ReadonlyArray<T> correctly becomes readonly T[] (verified in useLexicalCommandsLog.ts and vitest.setup.mts).
  • Flow files: Flow libdefs and .js.flow files 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.

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. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants