Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 5d62300

Browse files
committed
Add comment about why JS and JSX are handled with the TSX parser
1 parent 233a51c commit 5d62300

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Parsing/Parser.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,13 @@ someASTParser :: Language -> Maybe SomeASTParser
191191
someASTParser Go = Just (SomeASTParser (ASTParser tree_sitter_go :: Parser (AST [] Go.Grammar)))
192192
someASTParser Haskell = Just (SomeASTParser (ASTParser tree_sitter_haskell :: Parser (AST [] Haskell.Grammar)))
193193
someASTParser Java = Just (SomeASTParser (ASTParser tree_sitter_java :: Parser (AST [] Java.Grammar)))
194-
someASTParser JavaScript = Just (SomeASTParser (ASTParser tree_sitter_tsx :: Parser (AST [] TSX.Grammar)))
195194
someASTParser JSON = Just (SomeASTParser (ASTParser tree_sitter_json :: Parser (AST [] JSON.Grammar)))
195+
196+
-- Use the TSX parser for `.js` and `.jsx` files in case they use Flow type-annotation syntax.
197+
-- The TSX and Flow syntaxes are the same, whereas the normal TypeScript syntax is different.
198+
someASTParser JavaScript = Just (SomeASTParser (ASTParser tree_sitter_tsx :: Parser (AST [] TSX.Grammar)))
196199
someASTParser JSX = Just (SomeASTParser (ASTParser tree_sitter_tsx :: Parser (AST [] TSX.Grammar)))
200+
197201
someASTParser Python = Just (SomeASTParser (ASTParser tree_sitter_python :: Parser (AST [] Python.Grammar)))
198202
someASTParser Ruby = Just (SomeASTParser (ASTParser tree_sitter_ruby :: Parser (AST [] Ruby.Grammar)))
199203
someASTParser TypeScript = Just (SomeASTParser (ASTParser tree_sitter_typescript :: Parser (AST [] TypeScript.Grammar)))

0 commit comments

Comments
 (0)