mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 15:54:09 +00:00
Road to No explicit any: Group 8 (part 6) test files (#8344)
## Summary
This PR removes unsafe type assertions ("as unknown as Type") from test
files and improves type safety across the codebase.
### Key Changes
#### Type Safety Improvements
- Removed all instances of "as unknown as" patterns from test files
- Used proper factory functions from litegraphTestUtils instead of
custom mocks
- Made incomplete mocks explicit using Partial<T> types
- Fixed DialogStore mocking with proper interface exports
- Improved type safety with satisfies operator where applicable
#### App Parameter Removal
- **Removed the unused `app` parameter from all ComfyExtension interface
methods**
- The app parameter was always undefined at runtime as it was never
passed from invokeExtensions
- Affected methods: init, setup, addCustomNodeDefs,
beforeRegisterNodeDef, beforeRegisterVueAppNodeDefs,
registerCustomNodes, loadedGraphNode, nodeCreated, beforeConfigureGraph,
afterConfigureGraph
##### Breaking Change Analysis
Verified via Sourcegraph that this is NOT a breaking change:
- Searched all 10 affected methods across GitHub repositories
- Only one external repository
([drawthingsai/draw-things-comfyui](https://github.com/drawthingsai/draw-things-comfyui))
declares the app parameter in their extension methods
- That repository never actually uses the app parameter (just declares
it in the function signature)
- All other repositories already omit the app parameter
- Search queries used:
- [init method
search](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/.*+lang:typescript+%22init%28app%22+-repo:Comfy-Org/ComfyUI_frontend&patternType=standard)
- [setup method
search](https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/.*+lang:typescript+%22setup%28app%22+-repo:Comfy-Org/ComfyUI_frontend&patternType=standard)
- Similar searches for all 10 methods confirmed no usage
### Files Changed
Test files:
-
src/components/settings/widgets/__tests__/WidgetInputNumberInput.test.ts
- src/services/keybindingService.escape.test.ts
- src/services/keybindingService.forwarding.test.ts
- src/utils/__tests__/newUserService.test.ts →
src/utils/__tests__/useNewUserService.test.ts
- src/services/jobOutputCache.test.ts
-
src/renderer/extensions/vueNodes/widgets/composables/useRemoteWidget.test.ts
-
src/renderer/extensions/vueNodes/widgets/composables/useIntWidget.test.ts
-
src/renderer/extensions/vueNodes/widgets/composables/useFloatWidget.test.ts
Source files:
- src/types/comfy.ts - Removed app parameter from ComfyExtension
interface
- src/services/extensionService.ts - Improved type safety with
FunctionPropertyNames helper
- src/scripts/metadata/isobmff.ts - Fixed extractJson return type per
review
- src/extensions/core/*.ts - Updated extension implementations
- src/scripts/app.ts - Updated app initialization
### Testing
- All existing tests pass
- Type checking passes
- ESLint/oxlint checks pass
- No breaking changes for external repositories
Part of the "Road to No Explicit Any" initiative.
### Previous PRs in this series:
- Part 2: #7401
- Part 3: #7935
- Part 4: #7970
- Part 5: #8064
- Part 6: #8083
- Part 7: #8092
- Part 8 Group 1: #8253
- Part 8 Group 2: #8258
- Part 8 Group 3: #8304
- Part 8 Group 4: #8314
- Part 8 Group 5: #8329
- Part 8 Group 6: #8344 (this PR)
This commit is contained in:
committed by
GitHub
parent
868180eb28
commit
cabd08f0ec
@@ -134,18 +134,15 @@ export interface ComfyExtension {
|
||||
actionBarButtons?: ActionBarButton[]
|
||||
/**
|
||||
* Allows any initialisation, e.g. loading resources. Called after the canvas is created but before nodes are added
|
||||
* @param app The ComfyUI app instance
|
||||
*/
|
||||
init?(app: ComfyApp): Promise<void> | void
|
||||
/**
|
||||
* Allows any additional setup, called after the application is fully set up and running
|
||||
* @param app The ComfyUI app instance
|
||||
*/
|
||||
setup?(app: ComfyApp): Promise<void> | void
|
||||
/**
|
||||
* Called before nodes are registered with the graph
|
||||
* @param defs The collection of node definitions, add custom ones or edit existing ones
|
||||
* @param app The ComfyUI app instance
|
||||
*/
|
||||
addCustomNodeDefs?(
|
||||
defs: Record<string, ComfyNodeDef>,
|
||||
@@ -155,7 +152,6 @@ export interface ComfyExtension {
|
||||
// getCustomWidgets.
|
||||
/**
|
||||
* Allows the extension to add custom widgets
|
||||
* @param app The ComfyUI app instance
|
||||
* @returns An array of {[widget name]: widget data}
|
||||
*/
|
||||
getCustomWidgets?(app: ComfyApp): Promise<Widgets> | Widgets
|
||||
@@ -185,7 +181,7 @@ export interface ComfyExtension {
|
||||
* Allows the extension to add additional handling to the node before it is registered with **LGraph**
|
||||
* @param nodeType The node class (not an instance)
|
||||
* @param nodeData The original node object info config object
|
||||
* @param app The ComfyUI app instance
|
||||
* @param app The app instance
|
||||
*/
|
||||
beforeRegisterNodeDef?(
|
||||
nodeType: typeof LGraphNode,
|
||||
@@ -198,15 +194,13 @@ export interface ComfyExtension {
|
||||
* Modifications is expected to be made in place.
|
||||
*
|
||||
* @param defs The node definitions
|
||||
* @param app The ComfyUI app instance
|
||||
* @param app The app instance
|
||||
*/
|
||||
beforeRegisterVueAppNodeDefs?(defs: ComfyNodeDef[], app: ComfyApp): void
|
||||
|
||||
/**
|
||||
* Allows the extension to register additional nodes with LGraph after standard nodes are added.
|
||||
* Custom node classes should extend **LGraphNode**.
|
||||
*
|
||||
* @param app The ComfyUI app instance
|
||||
*/
|
||||
registerCustomNodes?(app: ComfyApp): Promise<void> | void
|
||||
/**
|
||||
@@ -214,13 +208,13 @@ export interface ComfyExtension {
|
||||
* If you break something in the backend and want to patch workflows in the frontend
|
||||
* This is the place to do this
|
||||
* @param node The node that has been loaded
|
||||
* @param app The ComfyUI app instance
|
||||
* @param app The app instance
|
||||
*/
|
||||
loadedGraphNode?(node: LGraphNode, app: ComfyApp): void
|
||||
/**
|
||||
* Allows the extension to run code after the constructor of the node
|
||||
* @param node The node that has been created
|
||||
* @param app The ComfyUI app instance
|
||||
* @param app The app instance
|
||||
*/
|
||||
nodeCreated?(node: LGraphNode, app: ComfyApp): void
|
||||
|
||||
@@ -228,18 +222,22 @@ export interface ComfyExtension {
|
||||
* Allows the extension to modify the graph data before it is configured.
|
||||
* @param graphData The graph data
|
||||
* @param missingNodeTypes The missing node types
|
||||
* @param app The app instance
|
||||
*/
|
||||
beforeConfigureGraph?(
|
||||
graphData: ComfyWorkflowJSON,
|
||||
missingNodeTypes: MissingNodeType[]
|
||||
missingNodeTypes: MissingNodeType[],
|
||||
app: ComfyApp
|
||||
): Promise<void> | void
|
||||
|
||||
/**
|
||||
* Allows the extension to run code after the graph is configured.
|
||||
* @param missingNodeTypes The missing node types
|
||||
* @param app The app instance
|
||||
*/
|
||||
afterConfigureGraph?(
|
||||
missingNodeTypes: MissingNodeType[]
|
||||
missingNodeTypes: MissingNodeType[],
|
||||
app: ComfyApp
|
||||
): Promise<void> | void
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user