feat(typescript): support .mts/.cts as TypeScript#310
Open
joptimus wants to merge 1 commit into
Open
Conversation
Files with the .mts (ESM) and .cts (CommonJS) TypeScript module extensions were skipped by the indexer because the TypeScript language spec only mapped .ts/.tsx, so they were detected as unknown (issue repowise-dev#288). .cts is included because it is the paired CommonJS module extension and shares the parser and resolver path. - Register .mts/.cts in the TypeScript language spec; they propagate to EXTENSION_TO_LANGUAGE automatically and route to the plain TypeScript grammar (only .tsx needs the JSX variant). - Resolve extensionless imports to .mts/.cts across all three resolvers: the relative resolver (probe list, directory-barrel /index.mts and /index.cts, and the fake-extension fallback), tsconfig path-alias resolution (_TS_EXTENSIONS, _INDEX_FILES), and workspace exports (_PROBE_EXTENSIONS). - Recognize .mts/.cts test files (.test.mts, .spec.cts, etc.) in every test-classification list: dead-code never-flag, health engine _is_test_file and _has_paired_test_file, hidden_coupling, coverage detector (_TEST_FILE_SUFFIXES and paired_test_file), and coverage_gap. Out of scope (follow-up): framework-edge route detection for module-script extensions (next_app, remix), and full Node ESM/CJS output-mapping semantics. Closes repowise-dev#288
|
✅ Health: 7.5 (unchanged)
🔥 Hotspot touched
2 more
🔗 Hidden coupling
Dead code
👀 Suggested reviewers @RaghavChamadiya 📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-05-29 15:30 UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Index, resolve, and analyze
.mts(ESM) and.cts(CommonJS) TypeScript module files as TypeScript instead of skipping them asunknown.Why
The TypeScript language spec only mapped
.ts/.tsx, so.mts/.ctsfiles were detected asunknownand skipped by the indexer (issue #288)..ctsis included because it is the paired CommonJS TypeScript module extension and shares the same parser and resolver path.How
.mts/.ctsin the TypeScript language spec. They propagate toEXTENSION_TO_LANGUAGEautomatically (it is derived from the spec registry) and route to the plain TypeScript grammar; only.tsxneeds the JSX variant, so.mts/.ctsfall through correctly..mts/.cts, including directory-barrelindex.mts/index.cts:resolvers/typescript.py): probe list +/index.mts,/index.cts+ the fake-extension fallback loop.tsconfig_resolver.py):_TS_EXTENSIONS,_INDEX_FILES.resolvers/ts_workspace.py):_PROBE_EXTENSIONS..mts/.ctsfiles are indexed they flow into analysis, so add.test.mts/.spec.ctsetc. to every test-classification list to avoid misflagging: dead-code never-flag, healthengine._is_test_fileandengine._has_paired_test_file,hidden_coupling, coveragedetector(_TEST_FILE_SUFFIXESandpaired_test_file), andcoverage_gap.Tests
TDD for each layer: language detection, parser smoke tests, all three resolvers (direct + index-barrel,
.mtsand.cts), dead-code never-flag, and the health classifiers (including the engine paired-test helper for a.mtssource). Full affected-area regression: 1136 passed, 2 xfailed.Out of scope (follow-up)
Framework-edge route detection for module-script extensions (
next_app.py,remix.py), and full Node ESM/CJS output-mapping semantics.This change is Python-only and does not touch
packages/web.Closes #288