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
- Open a TypeScript React project containing
.tsx files with JSX components (e.g., <Component />).
- Run
aider.
- Try to generate a repository map using
/map.
- 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",
Description
In
grep_ast/parsers.py,.tsxfiles 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 insideaiderwhen working with React-based TypeScript codebases.Location of the Bug
The extension mapping is hardcoded to
"typescript"for.tsxfiles in two separate locations insidegrep_ast/parsers.py(around lines 56 and 269):Steps to Reproduce
.tsxfiles with JSX components (e.g.,<Component />).aider./map..tsxfiles fail to parse correctly, or definitions inside JSX components are completely missing from the map.Expected Behavior
.tsxfiles 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.pyto route.tsxto"tsx":