From 8601bdb0ce5c107335ddc0853d359ea57894ec71 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:13:37 +0200 Subject: [PATCH] chore: improve strictness (#1228) Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> --- .../backend/src/managers/applicationManager.spec.ts | 3 ++- packages/backend/src/managers/gitManager.spec.ts | 3 ++- .../backend/src/workers/gpu/WinGPUDetector.spec.ts | 2 +- packages/backend/src/workers/gpu/WinGPUDetector.ts | 4 ++-- packages/backend/tsconfig.json | 11 ++++------- packages/frontend/src/Route.svelte | 2 +- packages/frontend/src/lib/ApplicationActions.svelte | 1 - packages/frontend/src/lib/RecipeDetails.svelte | 5 ----- .../src/lib/table/application/ColumnRecipe.svelte | 10 +--------- packages/frontend/src/pages/Playground.svelte | 2 -- packages/frontend/tsconfig.json | 3 +++ 11 files changed, 16 insertions(+), 30 deletions(-) diff --git a/packages/backend/src/managers/applicationManager.spec.ts b/packages/backend/src/managers/applicationManager.spec.ts index de130d38c..19dbd3838 100644 --- a/packages/backend/src/managers/applicationManager.spec.ts +++ b/packages/backend/src/managers/applicationManager.spec.ts @@ -176,7 +176,7 @@ describe('pullApplication', () => { } return false; }); - vi.spyOn(fs, 'statSync').mockImplementation((path: PathLike) => { + vi.spyOn(fs, 'statSync').mockImplementation((path: PathLike): fs.Stats => { path = path.toString(); if (path.endsWith('recipe1')) { const stat = new fs.Stats(); @@ -187,6 +187,7 @@ describe('pullApplication', () => { stat.isDirectory = () => false; return stat; } + throw new Error('should never be reached'); }); vi.spyOn(fs, 'readFileSync').mockImplementation(() => { return ''; diff --git a/packages/backend/src/managers/gitManager.spec.ts b/packages/backend/src/managers/gitManager.spec.ts index 15cfff235..1bc30c723 100644 --- a/packages/backend/src/managers/gitManager.spec.ts +++ b/packages/backend/src/managers/gitManager.spec.ts @@ -703,12 +703,13 @@ test('getBehindAhead', async () => { test('getTrackingBranch', async () => { const gitmanager = new GitManager(); - mocks.getConfigMock.mockImplementation(async ({ path }: { path: string }) => { + mocks.getConfigMock.mockImplementation(async ({ path }: { path: string }): Promise => { if (path === 'branch.my-branch.remote') { return 'origin'; } else if (path === 'branch.my-branch.merge') { return 'refs/heads/my-remote-branch'; } + throw new Error('should never been reached'); }); const result = await gitmanager.getTrackingBranch('path/to/repository', 'my-branch'); expect(result).toEqual('origin/my-remote-branch'); diff --git a/packages/backend/src/workers/gpu/WinGPUDetector.spec.ts b/packages/backend/src/workers/gpu/WinGPUDetector.spec.ts index 75a59b96a..614a3e01c 100644 --- a/packages/backend/src/workers/gpu/WinGPUDetector.spec.ts +++ b/packages/backend/src/workers/gpu/WinGPUDetector.spec.ts @@ -122,5 +122,5 @@ test('perform should handle errors and return an empty list', async () => { const detector = new WinGPUDetector(); - await expect(detector.perform()).rejects.toThrowError('Failed to get GPU information: test error'); + await expect(detector.perform()).rejects.toThrowError('Failed to get GPU information: Error: test error'); }); diff --git a/packages/backend/src/workers/gpu/WinGPUDetector.ts b/packages/backend/src/workers/gpu/WinGPUDetector.ts index 87e21417f..cc36fa846 100644 --- a/packages/backend/src/workers/gpu/WinGPUDetector.ts +++ b/packages/backend/src/workers/gpu/WinGPUDetector.ts @@ -77,7 +77,7 @@ export class WinGPUDetector extends WindowsWorker { const values = await this.getValues(subkey); return this.extractGpuInfo(values); } catch (error) { - console.error(`Error processing subkey: ${subkey.key}, error: ${error.message}`); + console.error(`Error processing subkey: ${subkey.key}, error: ${error}`); return undefined; } } @@ -95,7 +95,7 @@ export class WinGPUDetector extends WindowsWorker { const gpuInfos = await Promise.all(gpuInfoPromises); return gpuInfos.filter(info => info !== undefined) as IGPUInfo[]; } catch (error) { - throw new Error(`Failed to get GPU information: ${error.message}`); + throw new Error(`Failed to get GPU information: ${error}`); } } } diff --git a/packages/backend/tsconfig.json b/packages/backend/tsconfig.json index 9c24cb599..7e72472c6 100644 --- a/packages/backend/tsconfig.json +++ b/packages/backend/tsconfig.json @@ -19,13 +19,10 @@ "paths": { "@shared/*": ["../shared/*"] }, - "strictBindCallApply": true, - "alwaysStrict": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "noImplicitThis": true, - "noImplicitAny": true, - "strictPropertyInitialization": true + "strict": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noUnusedLocals": true, }, "include": [ "src", diff --git a/packages/frontend/src/Route.svelte b/packages/frontend/src/Route.svelte index 3c32cf64e..8d38acbbd 100644 --- a/packages/frontend/src/Route.svelte +++ b/packages/frontend/src/Route.svelte @@ -1,7 +1,7 @@
diff --git a/packages/frontend/src/pages/Playground.svelte b/packages/frontend/src/pages/Playground.svelte index db3a480f5..cf3b1b9f7 100644 --- a/packages/frontend/src/pages/Playground.svelte +++ b/packages/frontend/src/pages/Playground.svelte @@ -24,7 +24,6 @@ export let playgroundId: string; let prompt: string; let sendEnabled = false; let scrollable: Element; -let lastIsUserMessage = false; let errorMsg = ''; // settings @@ -41,7 +40,6 @@ $: { if (isSystemPrompt(latest) || (isAssistantChat(latest) && !isPendingChat(latest))) { sendEnabled = true; } - lastIsUserMessage = isUserChat(latest); } else { sendEnabled = true; } diff --git a/packages/frontend/tsconfig.json b/packages/frontend/tsconfig.json index 5432db6cc..a306b5254 100644 --- a/packages/frontend/tsconfig.json +++ b/packages/frontend/tsconfig.json @@ -4,6 +4,9 @@ "target": "esnext", "module": "esnext", "strict": true, + "noImplicitOverride": true, + "noUnusedLocals": true, + "noImplicitReturns": true, "resolveJsonModule": true, "preserveValueImports": false, "baseUrl": ".",