diff --git a/graphify/extract.py b/graphify/extract.py index a4ac6cbbd..01b69fc5c 100644 --- a/graphify/extract.py +++ b/graphify/extract.py @@ -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 diff --git a/tests/test_typescript_module_extensions.py b/tests/test_typescript_module_extensions.py index 41091a552..33c8493d2 100644 --- a/tests/test_typescript_module_extensions.py +++ b/tests/test_typescript_module_extensions.py @@ -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