Fixed 6 'as any' instances across 2 files:
- subgraphStore.test.ts: Used ReturnType for getUserData mock and ExportedSubgraph for subgraph serialization
- modelToNodeStore.test.ts: Used proper type casts for invalid input test cases
Fixed 10 'as any' instances across 5 files:
- keybindingService.escape.test.ts: Used ReturnType for dialog store mock
- nodeHelpStore.test.ts: Used ComfyNodeDefImpl type for node parameter
- comfyRegistryStore.test.ts: Used ReturnType for registry service mock
- domWidgetStore.test.ts: Used LGraphNode for mock node property
- executionStore.test.ts: Used LGraphNode for mock subgraph nodes
Fixed 6 'as any' instances across 3 files:
- LinkConnector.core.test.ts: Used Parameters utility type for method parameters
- useSelectionState.test.ts: Used ReturnType for composable and filter returns
- SubgraphNode.test.ts: Used SubgraphEventMap for event dispatch typing
Fixed 20 instances across:
- useWatchWidget.test.ts (5): Remove callback casts, call with proper args
- BypassButton.test.ts (5): Cast mock nodes as unknown as LGraphNode
- LinkConnector.test.ts (5): Use CanvasPointerEvent instead of Event, type render links properly
- executableGroupNodeChildDTO.test.ts (5): Cast to unknown as LGraphNode, use vi.mocked()
Key patterns:
- Widget callbacks now called with value argument
- Partial mock objects use as unknown as TargetType
- vi.mocked() wrapper for accessing mock methods after type casting
Fixed 31 instances across:
- typeGuardUtil.test.ts: Use Parameters utility type for partial mocks
- graphTraversalUtil.test.ts: Use proper type assertions for property mutations and invalid input testing
- subgraphNavigationStore.viewport.test.ts: Import Subgraph type, fix mock canvas typing
- useCanvasManager.test.ts: Use as unknown as Type for mutable mock store properties
- useCanvasTools.test.ts: Use as unknown as Type for mutable mock store properties
The canvas mock store pattern now uses as unknown as HTMLCanvasElement/CanvasRenderingContext2D
at both declaration and assignment points to allow partial mocks while maintaining type safety.
- Fixed 15 as any type assertions across 16 test files
- Used proper TypeScript types: unknown, Settings, ComfyWorkflowJSON, etc.
- Added missing type imports where needed
- Replaced as any with proper type intersections for Vue component testing
Files modified:
- ComboWidget.test.ts: Use explicit Values union type
- settingStore.test.ts: Import and use Settings type
- WhatsNewPopup.test.ts: Type assertion with component interface
- useMinimap.test.ts: Remove unnecessary cast (renderMinimap is public)
- LGraphNode.test.ts: Remove unnecessary any cast from undefined
- WidgetGalleria.test.ts: Type intersection for vm access
- WidgetInputNumberInput.test.ts: Use unknown to number cast
- jobOutputCache.test.ts: Import ComfyWorkflowJSON type
- mediaCacheService.test.ts: Use Partial<typeof URL> cast
- registrySearchProvider.test.ts: Use ReturnType<typeof store>
- firebaseAuthStore.test.ts: Cast to UserCredential
- queueStore.test.ts: Use Record<string, unknown> for delete
- usePacksSelection.test.ts: Cast undefined to unknown to string
- usePacksStatus.test.ts: Cast undefined to unknown to string
- useConflictDetection.test.ts: Use inline type for ImportFailInfo
Reduced as any count from 326 to 311 instances.
- modelStore.ts: Changed _findInMetadata metadata parameter from any to Record<string, unknown> with type guards
- surveyNormalization.ts: Changed normalizeSurveyResponses to use generic Record<string, unknown> constraint with proper type guards
- types.ts: Added index signature to SurveyResponses to allow normalized properties
- fuseUtil.ts: Changed isFuseSearchable type guard from any to unknown with proper null checks
- ui.ts: Changed Props index signature from any to unknown
- isobmff.ts: Changed extractJson return type from any to unknown with type assertion at call site
- clipspace.ts: Fixed pre-existing typecheck error by changing createImgSettings and createImgPreview to return null instead of empty array
- syncUtil: use UserDataFullInfo type from apiSchema for file parameters
- linkFixer: change logger parameters from any[] to unknown[]
- useChainCallback: use NonNullable and conditional types instead of any constraint
- FormRadioGroup: type modelValue as string | number | undefined
- async.ts: define GlobalWindow as typeof globalThis
- widgetInputs: use Parameters<NonNullable<T>> for callback parameters
- useWorkflowValidation: update logger to accept unknown[] parameters
- Use Parameters<NonNullable<T>> and ReturnType<NonNullable<T>> instead of custom CallbackParams/CallbackReturn types
- Change any[] to unknown[] in extensionService invokeExtensions methods
- Update contextMenuFilter.test.ts with type assertions for extension results
Remove explicit any types from 1 test file:
- subgraphNavigationStore.test.ts (11 instances)
Used typeof workflowStore.activeWorkflow to properly type workflow
mock assignments instead of the broader ComfyWorkflow type.
Remove explicit any types from 2 test files:
- firebaseAuthStore.test.ts (10 instances)
- useMinimapSettings.test.ts (10 instances)
Changes:
- Created MockAuth type for firebase auth mocks
- Used UserCredential type for firebase user credential mocks
- Used `ReturnType<typeof func>` to derive proper store types
- Changed Record<string, any> to Record<string, unknown>
All changes pass typecheck and tests.
Remove explicit any types from 3 test files:
- SubgraphMemory.test.ts (10 instances)
- minimapCanvasRenderer.test.ts (8 instances)
- useImageLoader.test.ts (8 instances)
Changes:
- Created InputWithWidget type for test-specific widget properties
- Used `unknown` type with proper type annotations for mock store properties
- Used `as unknown as T` pattern for mock objects
- Used `ReturnType<typeof func>` for store mock return types
All changes pass typecheck and tests.
Remove explicit any types from 7 test files:
- useWatchWidget.test.ts (3 instances)
- LGraphNodeProperties.test.ts (2 instances)
- versionCompatibilityStore.test.ts (2 instances)
- workflowStore.test.ts (2 instances)
- useRemoteWidget.test.ts (2 instances)
- registrySearchGateway.test.ts (2 instances)
- colorUtil.test.ts (2 instances)
Changes:
- Used `unknown` for truly unknown values instead of `any`
- Used `Partial<T>` with type assertions for mock objects
- Used `ReturnType<typeof func>` to derive proper types
- Used proper typing for promise resolvers and spy mocks
- Used `this: unknown` with proper casting for function contexts
All changes pass typecheck and tests.
- useMinimap.test.ts: Created comprehensive mock interfaces for Node, Graph, Canvas, CanvasElement, ContainerElement, and Context2D
- firebaseAuthStore.test.ts: Imported User type from firebase/auth and created MockUser type for mocking
Part 8 - Phase 5 complete: 2 files fixed, 14 any instances removed (9 + 5)
- releaseStore.test.ts: Created mock interfaces for ReleaseService, SettingStore, and SystemStatsStore with proper typing
- ExecuteButton.test.ts: Added Mock type interfaces for Canvas, CanvasStore, and CommandStore
- useManagerQueue.test.ts: Fixed Ref types and used correct ManagerPackInstalled schema types
Part 8 - Phase 4 complete: 8 files fixed, 32 any instances removed
- Change parameter types from string to unknown in both functions
- Functions already have type guards (typeof check) to handle invalid inputs
- Remove all 'as any' casts from tests - no longer needed
- Better type safety: functions now properly express they can handle any input
- Import SettingParams, SettingTreeNode types from settingStore
- Replace mockSettingStore: any with ReturnType<typeof useSettingStore>
- Replace mockSettings: any with properly typed Record<string, SettingParams> with double-cast
- Replace setting: any parameter with SettingParams in getSettingInfo mock
- Replace activeCategory as any with Partial<SettingTreeNode> and proper cast
- Add casts for dynamically assigned mock settings
- Define RegistryNodePack type from comfyRegistryTypes
- Create GlobalWithAlgolia interface for global properties
- Replace (global as any) with properly typed (globalThis as unknown as GlobalWithAlgolia)
- Type testPack and incompletePack as Partial<RegistryNodePack>
- Replace as any casts with as RegistryNodePack
- Replace ...args: any[] with proper return type annotations
- Replace (original as any).apply() with original.call()
- Replace (originalGetCanvasMenuOptions as any).apply() with .call()
- Add explicit return type (IContextMenuValue | null)[] to functions
- Import IContextMenuValue and LGraphNode types
- Replace ...args: any[] with proper parameter types (none for getCanvasMenuOptions, node: LGraphNode for getNodeMenuOptions)
- Replace (original as any).apply() with original.call() with proper typing
- Add explicit return type annotation for monkey-patched methods
- Import SystemStats type from apiSchema
- Replace null as any with proper SystemStats type
- Replace Promise<any> with Promise<SystemStats>
- Replace partial system object cast with SystemStats['system']
- Add necessary cast for empty object in test
- Define MockWebSocket interface with proper Mock types
- Replace mockWebSocket: any with MockWebSocket type
- Replace event: any with unknown in event handlers
- Import Mock type from vitest
- Update mockQueryParams type to include string[] for Vue Router query params
- Replace params?: any with unknown and inline type assertion
- Remove unnecessary 'as any' casts from array assignments
- Define NodeConstructorWithSlotOffset interface for constructor with optional slot_start_y
- Replace 3 'as any' casts with proper double-cast pattern
- All instances related to dynamic slot_start_y property on node constructor
- Define MockNodeInput interface for test inputs
- Replace widgets value: any with unknown
- Replace const node: any with proper object and double-cast to LGraphNode
- Add explicit return type boolean to isInputConnected
- Replace activeWorkflow mock with LoadedComfyWorkflow type and double-cast
- Replace selectedItems mocks with Positionable type and double-cast
- Import Mock type from vitest for checkState mock
- Define MockSettingStore interface with proper Mock types
- Create mockSettingStoreTyped with double-cast to useSettingStore return type
- Replace all mockSettingStore usages in initializeIfNewUser calls
- Import useSettingStore type from correct path
- Define MockSearchClient interface with search: Mock property
- Replace mockSearchClient: any with MockSearchClient type
- Apply double-cast when setting up mock return value
- Note: File still has other any instances for global properties and test casts
- Replace mockColorContext: any with proper MockColorContext interface
- Apply double-cast at draw() call sites to satisfy DefaultConnectionColors type
- Pattern: colorContext: mockColorContext as unknown as DefaultConnectionColors