Skip to content

Commit e1d186b

Browse files
tirth8205claude
andcommitted
fix(languages): add .mts/.cts extensions and *.spec.tsx test glob to the TypeScript config
The TypeScript LanguageConfig omitted the first-class .mts/.cts module extensions, so those files resolved to null and were skipped by the tree-sitter pipeline. It also listed *.test.tsx but not *.spec.tsx, miscategorizing spec-named TSX test files as regular source. Add .mts/.cts to extensions and *.spec.tsx to the test glob, mirroring the JavaScript config's .mjs/.cjs and test/spec parity. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fb1356a commit e1d186b

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

understand-anything-plugin/packages/core/src/__tests__/language-registry.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ describe("LanguageRegistry", () => {
7272
expect(registry.getByExtension(".h")?.id).toBe("c");
7373
expect(registry.getByExtension(".lua")?.id).toBe("lua");
7474
expect(registry.getByExtension(".js")?.id).toBe("javascript");
75+
expect(registry.getByExtension(".mts")?.id).toBe("typescript");
76+
expect(registry.getByExtension(".cts")?.id).toBe("typescript");
77+
expect(registry.getForFile("src/server.mts")?.id).toBe("typescript");
7578
});
7679

7780
it("has no duplicate extension mappings across configs", () => {
@@ -93,6 +96,13 @@ describe("LanguageRegistry", () => {
9396
});
9497
});
9598

99+
describe("typescript config test patterns", () => {
100+
it("recognizes both .test.tsx and .spec.tsx test files", () => {
101+
expect(typescriptConfig.filePatterns.tests).toContain("*.test.tsx");
102+
expect(typescriptConfig.filePatterns.tests).toContain("*.spec.tsx");
103+
});
104+
});
105+
96106
describe("Non-code language configs", () => {
97107
it("detects all non-code file types via extension", () => {
98108
const registry = LanguageRegistry.createDefault();

understand-anything-plugin/packages/core/src/languages/configs/typescript.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LanguageConfig } from "../types.js";
33
export const typescriptConfig = {
44
id: "typescript",
55
displayName: "TypeScript",
6-
extensions: [".ts", ".tsx"],
6+
extensions: [".ts", ".tsx", ".mts", ".cts"],
77
treeSitter: {
88
wasmPackage: "tree-sitter-typescript",
99
wasmFile: "tree-sitter-typescript.wasm",
@@ -24,7 +24,7 @@ export const typescriptConfig = {
2424
filePatterns: {
2525
entryPoints: ["src/index.ts", "src/main.ts", "src/App.tsx", "index.ts"],
2626
barrels: ["index.ts"],
27-
tests: ["*.test.ts", "*.spec.ts", "*.test.tsx"],
27+
tests: ["*.test.ts", "*.spec.ts", "*.test.tsx", "*.spec.tsx"],
2828
config: ["tsconfig.json"],
2929
},
3030
} satisfies LanguageConfig;

0 commit comments

Comments
 (0)