Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions graphify/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,9 +1051,10 @@ def extract_python(path: Path) -> dict:

def extract_js(path: Path) -> dict:
"""Extract classes, functions, arrow functions, and imports from a .js/.ts/.tsx/.mts/.cts file."""
if path.suffix == ".tsx":
suffix = path.suffix.lower()
if suffix == ".tsx":
config = _TSX_CONFIG
elif path.suffix in (".ts", ".mts", ".cts"):
elif suffix in (".ts", ".mts", ".cts"):
config = _TS_CONFIG
else:
config = _JS_CONFIG
Expand Down
7 changes: 7 additions & 0 deletions tests/test_typescript_module_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def test_cts_uses_the_typescript_grammar(tmp_path):
}


def test_uppercase_typescript_extensions_use_typescript_grammar(tmp_path):
for ext in (".TS", ".TSX", ".MTS", ".CTS"):
labels = _labels(_extract(tmp_path, ext))
assert any("Mode" in label for label in labels), f"TS `type` alias missing for {ext}"
assert any("Options" in label for label in labels), f"TS `interface` missing for {ext}"


def test_mts_cts_route_to_extract_js():
from graphify.extract import _DISPATCH, extract_js
assert _DISPATCH.get(".mts") is extract_js
Expand Down