Skip to content

Commit

Permalink
chore: improve strictness (#1228)
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 authored Jun 18, 2024
1 parent c0845ef commit 8601bdb
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 30 deletions.
3 changes: 2 additions & 1 deletion packages/backend/src/managers/applicationManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -187,6 +187,7 @@ describe('pullApplication', () => {
stat.isDirectory = () => false;
return stat;
}
throw new Error('should never be reached');
});
vi.spyOn(fs, 'readFileSync').mockImplementation(() => {
return '';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/managers/gitManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> => {
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');
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/workers/gpu/WinGPUDetector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
4 changes: 2 additions & 2 deletions packages/backend/src/workers/gpu/WinGPUDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class WinGPUDetector extends WindowsWorker<void, IGPUInfo[]> {
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;
}
}
Expand All @@ -95,7 +95,7 @@ export class WinGPUDetector extends WindowsWorker<void, IGPUInfo[]> {
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}`);
}
}
}
11 changes: 4 additions & 7 deletions packages/backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/Route.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { createRouteObject } from 'tinro/dist/tinro_lib';
import type { TinroRouteMeta } from 'tinro';
import { saveRouterState, studioClient } from '/@/utils/client';
import { saveRouterState } from '/@/utils/client';
export let path = '/*';
export let fallback = false;
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/src/lib/ApplicationActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type { ApplicationState } from '@shared/src/models/IApplicationState';
import { router } from 'tinro';
import DropDownMenu from './DropDownMenu.svelte';
import FlatMenu from './FlatMenu.svelte';
import { onMount } from 'svelte';
export let object: ApplicationState | undefined;
export let recipeId: string;
export let modelId: string;
Expand Down
5 changes: 0 additions & 5 deletions packages/frontend/src/lib/RecipeDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { tasks } from '/@/stores/tasks';
import { filterByLabel } from '/@/utils/taskUtils';
import PodIcon from '/@/lib/images/PodIcon.svelte';
import StatusIcon from '/@/lib/StatusIcon.svelte';
import type { ModelInfo } from '@shared/src/models/IModelInfo';
import { getApplicationStatus, getApplicationStatusText } from '../pages/applications';
import { Button, Spinner } from '@podman-desktop/ui-svelte';
Expand Down Expand Up @@ -57,10 +56,6 @@ const navigateToPod = () => {
}
};
function findModel(id: string | undefined): ModelInfo | undefined {
return $catalog.models.find(m => m.id === id);
}
function startApplication() {
studioClient.pullApplication(recipeId, modelId).catch((err: unknown) => {
console.error('Something went wrong while pulling AI App', err);
Expand Down
10 changes: 1 addition & 9 deletions packages/frontend/src/lib/table/application/ColumnRecipe.svelte
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
<script lang="ts">
import { catalog } from '/@/stores/catalog';
import { displayPorts } from '/@/utils/printers';
import { faSquareArrowUpRight } from '@fortawesome/free-solid-svg-icons';
import { studioClient } from '/@/utils/client';
import Fa from 'svelte-fa';
import type { ApplicationState } from '@shared/src/models/IApplicationState';
export let object: ApplicationState;
let name: string | undefined;
$: name = $catalog.recipes.find(r => r.id === object.recipeId)?.name;
function openApp(port: number) {
studioClient.openURL(`http://localhost:${port}`).catch((err: unknown) => {
console.error('Something went wrong while opening url', err);
});
}
</script>

<div class="flex flex-col">
Expand Down
2 changes: 0 additions & 2 deletions packages/frontend/src/pages/Playground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export let playgroundId: string;
let prompt: string;
let sendEnabled = false;
let scrollable: Element;
let lastIsUserMessage = false;
let errorMsg = '';
// settings
Expand All @@ -41,7 +40,6 @@ $: {
if (isSystemPrompt(latest) || (isAssistantChat(latest) && !isPendingChat(latest))) {
sendEnabled = true;
}
lastIsUserMessage = isUserChat(latest);
} else {
sendEnabled = true;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"target": "esnext",
"module": "esnext",
"strict": true,
"noImplicitOverride": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"resolveJsonModule": true,
"preserveValueImports": false,
"baseUrl": ".",
Expand Down

0 comments on commit 8601bdb

Please sign in to comment.