Skip to content

Commit 77edc2c

Browse files
committed
fix: satisfy upgraded TypeScript checks
1 parent 531e310 commit 77edc2c

11 files changed

Lines changed: 60 additions & 47 deletions

File tree

apps/desktop-ui/.storybook/preview.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const preview: Preview = {
7777
{ value: 'light', icon: 'sun', title: 'Light' },
7878
{ value: 'dark', icon: 'moon', title: 'Dark' }
7979
],
80-
showName: true,
8180
dynamicTitle: true
8281
}
8382
}

apps/desktop-ui/src/composables/bottomPanelTabs/useTerminal.test.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest'
22
import { ref } from 'vue'
33

4-
const { mockTerminal, MockTerminal, mockFitAddon, MockFitAddon } = vi.hoisted(
5-
() => {
6-
const mockTerminal = {
7-
loadAddon: vi.fn(),
8-
attachCustomKeyEventHandler: vi.fn(),
9-
open: vi.fn(),
10-
dispose: vi.fn(),
11-
hasSelection: vi.fn<[], boolean>(),
12-
resize: vi.fn(),
13-
cols: 80,
14-
rows: 24
15-
}
16-
const MockTerminal = vi.fn(function () {
17-
return mockTerminal
18-
})
19-
20-
const mockFitAddon = {
21-
proposeDimensions: vi.fn().mockReturnValue({ cols: 80, rows: 24 })
22-
}
23-
const MockFitAddon = vi.fn(function () {
24-
return mockFitAddon
25-
})
4+
const { mockTerminal, MockTerminal, MockFitAddon } = vi.hoisted(() => {
5+
const mockTerminal = {
6+
loadAddon: vi.fn(),
7+
attachCustomKeyEventHandler: vi.fn(),
8+
open: vi.fn(),
9+
dispose: vi.fn(),
10+
hasSelection: vi.fn<() => boolean>(),
11+
resize: vi.fn(),
12+
cols: 80,
13+
rows: 24
14+
}
15+
const MockTerminal = vi.fn(function () {
16+
return mockTerminal
17+
})
2618

27-
return { mockTerminal, MockTerminal, mockFitAddon, MockFitAddon }
19+
const mockFitAddon = {
20+
proposeDimensions: vi.fn().mockReturnValue({ cols: 80, rows: 24 })
2821
}
29-
)
22+
const MockFitAddon = vi.fn(function () {
23+
return mockFitAddon
24+
})
25+
26+
return { mockTerminal, MockTerminal, MockFitAddon }
27+
})
3028

3129
vi.mock('@xterm/xterm', () => ({ Terminal: MockTerminal }))
3230
vi.mock('@xterm/addon-fit', () => ({ FitAddon: MockFitAddon }))

apps/desktop-ui/src/composables/bottomPanelTabs/useTerminalBuffer.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { beforeEach, describe, expect, it, vi } from 'vitest'
22

33
const { mockSerialize, MockSerializeAddon } = vi.hoisted(() => {
4-
const mockSerialize = vi.fn<[], string>()
4+
const mockSerialize = vi.fn<() => string>()
55
const MockSerializeAddon = vi.fn(function () {
66
return { serialize: mockSerialize }
77
})
@@ -33,15 +33,15 @@ describe('useTerminalBuffer', () => {
3333
mockSerialize.mockReturnValue('hello world')
3434
const { copyTo } = withSetup(() => useTerminalBuffer())
3535
const mockWrite = vi.fn()
36-
copyTo({ write: mockWrite } as Pick<Terminal, 'write'>)
36+
copyTo({ write: mockWrite } as unknown as Terminal)
3737
expect(mockWrite).toHaveBeenCalledWith('hello world')
3838
})
3939

4040
it('writes empty string when buffer is empty', () => {
4141
mockSerialize.mockReturnValue('')
4242
const { copyTo } = withSetup(() => useTerminalBuffer())
4343
const mockWrite = vi.fn()
44-
copyTo({ write: mockWrite } as Pick<Terminal, 'write'>)
44+
copyTo({ write: mockWrite } as unknown as Terminal)
4545
expect(mockWrite).toHaveBeenCalledWith('')
4646
})
4747
})

apps/desktop-ui/src/constants/desktopDialogs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('getDialog', () => {
2828
it('returns a deep clone — mutations do not affect the original', () => {
2929
const result = getDialog('reinstallVenv')
3030
const originalFirstLabel = DESKTOP_DIALOGS.reinstallVenv.buttons[0].label
31-
result.buttons[0].label = 'Mutated'
31+
;(result.buttons as Array<{ label: string }>)[0].label = 'Mutated'
3232
expect(DESKTOP_DIALOGS.reinstallVenv.buttons[0].label).toBe(
3333
originalFirstLabel
3434
)

apps/desktop-ui/src/constants/desktopMaintenanceTasks.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
33
const { mockElectron } = vi.hoisted(() => ({
44
mockElectron: {
55
setBasePath: vi.fn(),
6-
reinstall: vi.fn<[], Promise<void>>().mockResolvedValue(undefined),
6+
reinstall: vi.fn<() => Promise<void>>().mockResolvedValue(undefined),
77
uv: {
8-
installRequirements: vi.fn<[], Promise<void>>(),
9-
clearCache: vi.fn<[], Promise<void>>().mockResolvedValue(undefined),
10-
resetVenv: vi.fn<[], Promise<void>>().mockResolvedValue(undefined)
8+
installRequirements: vi.fn<() => Promise<void>>(),
9+
clearCache: vi.fn<() => Promise<void>>().mockResolvedValue(undefined),
10+
resetVenv: vi.fn<() => Promise<void>>().mockResolvedValue(undefined)
1111
}
1212
}
1313
}))
@@ -48,24 +48,24 @@ describe('desktopMaintenanceTasks', () => {
4848
})
4949

5050
describe('URL-opening tasks', () => {
51-
it('git execute opens the git download page', () => {
52-
findTask('git').execute()
51+
it('git execute opens the git download page', async () => {
52+
expect(await findTask('git').execute()).toBe(true)
5353
expect(window.open).toHaveBeenCalledWith(
5454
'https://git-scm.com/downloads/',
5555
'_blank'
5656
)
5757
})
5858

59-
it('uv execute opens the uv installation page', () => {
60-
findTask('uv').execute()
59+
it('uv execute opens the uv installation page', async () => {
60+
expect(await findTask('uv').execute()).toBe(true)
6161
expect(window.open).toHaveBeenCalledWith(
6262
'https://docs.astral.sh/uv/getting-started/installation/',
6363
'_blank'
6464
)
6565
})
6666

67-
it('vcRedist execute opens the VC++ redistributable download', () => {
68-
findTask('vcRedist').execute()
67+
it('vcRedist execute opens the VC++ redistributable download', async () => {
68+
expect(await findTask('vcRedist').execute()).toBe(true)
6969
expect(window.open).toHaveBeenCalledWith(
7070
'https://aka.ms/vs/17/release/vc_redist.x64.exe',
7171
'_blank'

apps/desktop-ui/src/utils/electronMirrorCheck.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
33
const { mockElectron } = vi.hoisted(() => ({
44
mockElectron: {
55
NetWork: {
6-
canAccessUrl: vi.fn<[url: string], Promise<boolean>>()
6+
canAccessUrl: vi.fn<(url: string) => Promise<boolean>>()
77
}
88
}
99
}))

apps/desktop-ui/src/utils/envUtil.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import type { ElectronAPI } from '@comfyorg/comfyui-electron-types'
22

3+
export type ElectronWindow = typeof window & {
4+
electronAPI: Record<string, unknown> & {
5+
Config: Record<string, unknown>
6+
}
7+
}
8+
39
export function isElectron() {
410
return 'electronAPI' in window && window.electronAPI !== undefined
511
}
612

713
export function electronAPI() {
8-
return (window as any).electronAPI as ElectronAPI
14+
return (window as ElectronWindow).electronAPI as ElectronAPI
915
}
1016

1117
export function isNativeWindow() {

apps/desktop-ui/tsconfig.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
"paths": {
77
"@/*": ["./src/*"],
88
"@frontend-locales/*": ["../../src/locales/*"]
9-
}
9+
},
10+
"types": [
11+
"vite/client",
12+
"vitest/globals",
13+
"@webgpu/types",
14+
"@testing-library/jest-dom/vitest"
15+
]
1016
},
1117
"include": [
1218
".storybook/**/*",

packages/shared-frontend-utils/src/piiUtil.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22

33
import { createPostHogBeforeSend } from './piiUtil'
4+
import type { PostHogEventLike } from './piiUtil'
45

56
describe('createPostHogBeforeSend', () => {
67
const beforeSend = createPostHogBeforeSend()
@@ -10,7 +11,7 @@ describe('createPostHogBeforeSend', () => {
1011
})
1112

1213
it('strips all PII keys from properties, $set, and $set_once', () => {
13-
const event = {
14+
const event: PostHogEventLike = {
1415
properties: {
1516
email: 'a@example.com',
1617
prompt: 'hello',
@@ -48,7 +49,9 @@ describe('createPostHogBeforeSend', () => {
4849
})
4950

5051
it('handles missing property bags gracefully', () => {
51-
const event = { properties: { email: 'a@example.com', safe: true } }
52+
const event: PostHogEventLike = {
53+
properties: { email: 'a@example.com', safe: true }
54+
}
5255
const result = beforeSend(event)!
5356
expect(result.properties).not.toHaveProperty('email')
5457
expect(result.properties).toHaveProperty('safe', true)

packages/shared-frontend-utils/src/piiUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function stripPiiKeys(obj?: Record<string, unknown>): void {
1616
*
1717
* Ref: posthog.com/tutorials/web-redact-properties
1818
*/
19-
interface PostHogEventLike {
19+
export interface PostHogEventLike {
2020
properties?: Record<string, unknown>
2121
$set?: Record<string, unknown>
2222
$set_once?: Record<string, unknown>

0 commit comments

Comments
 (0)