Skip to content

Upstream tracking: tree-sitter-javascript fails on Flow type annotations and drops subsequent functions #2163

Description

@squid-protocol

Description

During a tri-comparison ledger sweep, we identified a persistent parser limitation in tree-sitter-javascript when encountering Flow type annotations (e.g. @flow pragma in react/*).

The plain JavaScript tree-sitter grammar cannot parse Flow's parenthesized type-cast syntax ((expr: Type)), producing an ERROR node that swallows large trailing regions of the file. Any real functions inside these regions (like beginWork, mountLazyComponent) are entirely missed by tree-sitter.

GitGalaxy's structural extraction regex has no dependency on the parse state and correctly finds every one of these functions.

Scope

  • Affects react/ReactFiberBeginWork.js, ReactFiberWorkLoop.js, ReactFlightServer.js, etc.
  • Accounts for ~183 functions that GitGalaxy correctly captures but tree-sitter misses.

Action

This is an upstream tree-sitter limitation (or requires a dedicated Flow grammar instead of plain JS). Documented in docs/why_gitgalaxy_beats_ast_here.md. Tracking here for visibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core-engineModifications to the central physics and parsing enginetestingUnit, integration, and E2E pipeline verification

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions