fix(extract): recognize uppercase TypeScript

This commit is contained in:
xkam7ar
2026-07-14 23:32:02 +01:00
committed by safishamsi
parent 4f6106a2f1
commit 8361a81f73
2 changed files with 10 additions and 2 deletions
+3 -2
View File
@@ -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
@@ -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