Skip to content

Commit c5addb0

Browse files
committed
fix: Resolve TypeScript issues in test suite
- Fix Mocha constructor usage with proper type casting - Add explicit type annotations for callback parameters - Remove unused variable in OpenAiService - Ensure proper return types for Promise callbacks - Fix glob import to use named import syntax
1 parent 6ae9a54 commit c5addb0

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/service/OpenAiService.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,12 @@ class OpenAiService implements AIService {
4343
async getCommitMessageFromDiff(
4444
code: string,
4545
openAIKey: string,
46-
nameOnly?: boolean,
46+
_nameOnly?: boolean,
4747
progress?: vscode.Progress<{
4848
message?: string | undefined;
4949
increment?: number | undefined;
5050
}>,
5151
): Promise<string | null> {
52-
let _gitCmd = "git diff --cached";
53-
if (nameOnly) {
54-
_gitCmd = "git diff --cached --name-status";
55-
}
5652
const instructions = WorkspaceService.getInstance().getAIInstructions();
5753
if (!instructions) {
5854
return null;

src/test/suite/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import * as path from "node:path";
2-
import * as glob from "glob";
2+
import { glob } from "glob";
33
import * as Mocha from "mocha";
44

55
export function run(): Promise<void> {
66
// Create the mocha test
7-
const mocha = new Mocha({
7+
const mocha = new (Mocha as any)({
88
ui: "tdd",
99
color: true,
1010
});
1111

1212
const testsRoot = path.resolve(__dirname, "..");
1313

14-
return new Promise((c, e) => {
15-
glob("**/**.test.js", { cwd: testsRoot }, (err, files) => {
14+
return new Promise<void>((c, e) => {
15+
glob("**/**.test.js", { cwd: testsRoot }, (err: Error | null, files: string[]) => {
1616
if (err) {
1717
return e(err);
1818
}
1919

2020
// Add files to the test suite
21-
files.forEach((f) => {
21+
files.forEach((f: string) => {
2222
mocha.addFile(path.resolve(testsRoot, f));
2323
});
2424

2525
try {
2626
// Run the mocha test
27-
mocha.run((failures) => {
27+
mocha.run((failures: number) => {
2828
if (failures > 0) {
2929
e(new Error(`${failures} tests failed.`));
3030
} else {
@@ -33,7 +33,7 @@ export function run(): Promise<void> {
3333
});
3434
} catch (err) {
3535
console.error(err);
36-
e(err);
36+
e(err as Error);
3737
}
3838
});
3939
});

0 commit comments

Comments
 (0)