Skip to content

Bug: .tsx files are hardcoded to "typescript" parser in parsers.py, causing Tree-sitter parsing failures #21

Description

@rishal-raj

Description

In grep_ast/parsers.py, .tsx files are mapped to the standard "typescript" Tree-sitter parser instead of the distinct "tsx" parser. Because Tree-sitter treats TypeScript and TSX as entirely separate grammars due to conflicting syntax rules (such as how < and > angle brackets are parsed), attempting to parse React TSX components with the base TypeScript grammar causes syntax errors.

This directly results in broken repository maps (/map) and context tracking inside aider when working with React-based TypeScript codebases.

Location of the Bug

The extension mapping is hardcoded to "typescript" for .tsx files in two separate locations inside grep_ast/parsers.py (around lines 56 and 269):

# Standard mapping block
".tsx": "typescript",
".ts": "typescript",

# ...

# USING_TSL_PACK mapping block
".tsx": "typescript",
".ts": "typescript",

Steps to Reproduce

  1. Open a TypeScript React project containing .tsx files with JSX components (e.g., <Component />).
  2. Run aider.
  3. Try to generate a repository map using /map.
  4. Observe that .tsx files fail to parse correctly, or definitions inside JSX components are completely missing from the map.

Expected Behavior

.tsx files should be mapped to the "tsx" parser so that Tree-sitter can properly parse JSX syntax embedded in TypeScript files.

Proposed Fix

Update both mapping blocks in grep_ast/parsers.py to route .tsx to "tsx":

".tsx": "tsx",
".ts": "typescript",

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions