Remove fake Typecheck tool

This commit is contained in:
Alex Gleason committed 2025-12-07 00:26:43 -06:00
1 parent 8b193c3a33
commit ff51fa2f77
5 files changed
+2 -93

No files matched your search

-48
View File
@@ -1,48 +0,0 @@
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { TypecheckTool } from './TypecheckTool';
import type { JSRuntimeFS } from '../JSRuntime';
describe('TypecheckTool', () => {
let mockFS: JSRuntimeFS;
let tool: TypecheckTool;
beforeEach(() => {
vi.clearAllMocks();
mockFS = {
readFile: vi.fn(),
} as unknown as JSRuntimeFS;
tool = new TypecheckTool(mockFS, '/test/project');
});
it('should have correct description', () => {
expect(tool.description).toBe('Run TypeScript type checking on the project to verify there are no type errors.');
});
it('should fail if tsconfig.json does not exist', async () => {
vi.mocked(mockFS.readFile).mockRejectedValue(new Error('File not found'));
await expect(tool.execute()).rejects.toThrow(
'❌ Could not find tsconfig.json at /test/project. Make sure you\'re in a valid TypeScript project.'
);
});
it('should successfully return no type errors (stub implementation)', async () => {
vi.mocked(mockFS.readFile).mockResolvedValue('{"compilerOptions": {}}'); // tsconfig.json exists
const result = await tool.execute();
expect(result).toContain('✅ No type errors found.');
expect(result).toContain('🔍 TypeScript compilation completed successfully.');
expect(result).toContain('📁 Project: /test/project');
});
it('should handle file system errors gracefully', async () => {
vi.mocked(mockFS.readFile).mockRejectedValue(new Error('Permission denied'));
await expect(tool.execute()).rejects.toThrow(
'❌ Could not find tsconfig.json at /test/project. Make sure you\'re in a valid TypeScript project.'
);
});
});
-35
View File
@@ -1,35 +0,0 @@
import type { Tool } from "./Tool";
import type { JSRuntimeFS } from "../JSRuntime";
export class TypecheckTool implements Tool<void> {
private fs: JSRuntimeFS;
private cwd: string;
readonly description = "Run TypeScript type checking on the project to verify there are no type errors.";
constructor(fs: JSRuntimeFS, cwd: string) {
this.fs = fs;
this.cwd = cwd;
}
async execute(): Promise<string> {
// TODO: Add actual typechecking functionality
// This should run TypeScript compiler in --noEmit mode to check for type errors
// Similar to how the test script runs: tsc --noEmit
try {
// Check if we're in a valid TypeScript project
try {
await this.fs.readFile(`${this.cwd}/tsconfig.json`, "utf8");
} catch {
throw new Error(`❌ Could not find tsconfig.json at ${this.cwd}. Make sure you're in a valid TypeScript project.`);
}
// TODO: Implement actual TypeScript compilation check
// For now, return a success message as a stub
return "✅ No type errors found.\n\n🔍 TypeScript compilation completed successfully.\n📁 Project: " + this.cwd;
} catch (error) {
throw new Error(`❌ Type check failed: ${String(error)}`);
}
}
}