[fix] Remove TypeScript declare modifiers from class properties

This commit is contained in:
snomiao
2025-09-16 13:44:50 +00:00
parent 631746939a
commit 38291bee51
10 changed files with 34 additions and 29 deletions

View File

@@ -11,7 +11,7 @@ const nodeDefsPath = './src/locales/en/nodeDefs.json'
test('collect-i18n-node-defs', async ({ comfyPage }) => {
// Mock view route
comfyPage.page.route('**/view**', async (route) => {
await comfyPage.page.route('**/view**', async (route) => {
await route.fulfill({
body: JSON.stringify({})
})

View File

@@ -404,8 +404,8 @@ export class LGraphNode
selected?: boolean
showAdvanced?: boolean
declare comfyClass?: string
declare isVirtualNode?: boolean
comfyClass?: string
isVirtualNode?: boolean
applyToGraph?(extraLinks?: LLink[]): void
isSubgraphNode(): this is SubgraphNode {

View File

@@ -14,7 +14,9 @@ import type {
import type { INodeInputSlot } from '@/lib/litegraph/src/interfaces'
import type { Point } from '@/lib/litegraph/src/interfaces'
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
import type { SubgraphInputNode } from '@/lib/litegraph/src/subgraph/SubgraphInputNode'
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
import type { SubgraphOutputNode } from '@/lib/litegraph/src/subgraph/SubgraphOutputNode'
import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
import type { RenderLink } from './RenderLink'
@@ -175,7 +177,9 @@ export class FloatingRenderLink implements RenderLink {
): void {
const floatingLink = this.link
floatingLink.origin_id = SUBGRAPH_INPUT_ID
floatingLink.origin_slot = input.parent.slots.indexOf(input)
floatingLink.origin_slot = (
input.parent as SubgraphInputNode
).slots.indexOf(input)
this.fromSlot._floatingLinks?.delete(floatingLink)
input._floatingLinks ??= new Set()
@@ -188,7 +192,9 @@ export class FloatingRenderLink implements RenderLink {
): void {
const floatingLink = this.link
floatingLink.origin_id = SUBGRAPH_OUTPUT_ID
floatingLink.origin_slot = output.parent.slots.indexOf(output)
floatingLink.origin_slot = (
output.parent as SubgraphOutputNode
).slots.indexOf(output)
this.fromSlot._floatingLinks?.delete(floatingLink)
output._floatingLinks ??= new Set()

View File

@@ -12,8 +12,6 @@ import type { SubgraphInputNode } from './SubgraphInputNode'
* A virtual slot that simply creates a new input slot when connected to.
*/
export class EmptySubgraphInput extends SubgraphInput {
declare parent: SubgraphInputNode
constructor(parent: SubgraphInputNode) {
super(
{
@@ -30,7 +28,7 @@ export class EmptySubgraphInput extends SubgraphInput {
node: LGraphNode,
afterRerouteId?: RerouteId
): LLink | undefined {
const { subgraph } = this.parent
const { subgraph } = this.parent as SubgraphInputNode
const existingNames = subgraph.inputs.map((x) => x.name)
const name = nextUniqueName(slot.name, existingNames)

View File

@@ -12,8 +12,6 @@ import type { SubgraphOutputNode } from './SubgraphOutputNode'
* A virtual slot that simply creates a new output slot when connected to.
*/
export class EmptySubgraphOutput extends SubgraphOutput {
declare parent: SubgraphOutputNode
constructor(parent: SubgraphOutputNode) {
super(
{
@@ -30,7 +28,7 @@ export class EmptySubgraphOutput extends SubgraphOutput {
node: LGraphNode,
afterRerouteId?: RerouteId
): LLink | undefined {
const { subgraph } = this.parent
const { subgraph } = this.parent as SubgraphOutputNode
const existingNames = subgraph.outputs.map((x) => x.name)
const name = nextUniqueName(slot.name, existingNames)

View File

@@ -30,8 +30,6 @@ import { isNodeSlot, isSubgraphOutput } from './subgraphUtils'
* Functionally, however, when editing a subgraph, that "subgraph input" is the "origin" or "output side" of a link.
*/
export class SubgraphInput extends SubgraphSlot {
declare parent: SubgraphInputNode
events = new CustomEventTarget<SubgraphInputEventMap>()
/** The linked widget that this slot is connected to. */
@@ -50,13 +48,13 @@ export class SubgraphInput extends SubgraphSlot {
node: LGraphNode,
afterRerouteId?: RerouteId
): LLink | undefined {
const { subgraph } = this.parent
const parent = this.parent as SubgraphInputNode
const { subgraph } = parent
// Allow nodes to block connection
const inputIndex = node.inputs.indexOf(slot)
if (
node.onConnectInput?.(inputIndex, this.type, this, this.parent, -1) ===
false
node.onConnectInput?.(inputIndex, this.type, this, parent, -1) === false
)
return
@@ -77,7 +75,7 @@ export class SubgraphInput extends SubgraphSlot {
if (slot.link != null) {
subgraph.beforeChange()
const link = subgraph.getLink(slot.link)
this.parent._disconnectNodeInput(node, slot, link)
parent._disconnectNodeInput(node, slot, link)
}
const inputWidget = node.getWidgetFromSlot(slot)
@@ -97,8 +95,8 @@ export class SubgraphInput extends SubgraphSlot {
const link = new LLink(
++subgraph.state.lastLinkId,
slot.type,
this.parent.id,
this.parent.slots.indexOf(this),
parent.id,
parent.slots.indexOf(this),
node.id,
inputIndex,
afterRerouteId

View File

@@ -35,7 +35,8 @@ import type { SubgraphInput } from './SubgraphInput'
* An instance of a {@link Subgraph}, displayed as a node on the containing (parent) graph.
*/
export class SubgraphNode extends LGraphNode implements BaseLGraph {
declare inputs: (INodeInputSlot & Partial<ISubgraphInput>)[]
// Override inputs with proper typing for subgraph inputs
override inputs: (INodeInputSlot & Partial<ISubgraphInput>)[] = []
override readonly type: UUID
override readonly isVirtualNode = true as const

View File

@@ -29,14 +29,13 @@ import { isNodeSlot, isSubgraphInput } from './subgraphUtils'
* Functionally, however, when editing a subgraph, that "subgraph output" is the "target" or "input side" of a link.
*/
export class SubgraphOutput extends SubgraphSlot {
declare parent: SubgraphOutputNode
override connect(
slot: INodeOutputSlot,
node: LGraphNode,
afterRerouteId?: RerouteId
): LLink | undefined {
const { subgraph } = this.parent
const parent = this.parent as SubgraphOutputNode
const { subgraph } = parent
// Validate type compatibility
if (!LiteGraph.isValidConnection(slot.type, this.type)) return
@@ -47,8 +46,7 @@ export class SubgraphOutput extends SubgraphSlot {
throw new Error('Slot is not an output of the given node')
if (
node.onConnectOutput?.(outputIndex, this.type, this, this.parent, -1) ===
false
node.onConnectOutput?.(outputIndex, this.type, this, parent, -1) === false
)
return
@@ -68,8 +66,8 @@ export class SubgraphOutput extends SubgraphSlot {
slot.type,
node.id,
outputIndex,
this.parent.id,
this.parent.slots.indexOf(this),
parent.id,
parent.slots.indexOf(this),
afterRerouteId
)

View File

@@ -47,8 +47,8 @@ export abstract class BaseWidget<TWidget extends IBaseWidget = IBaseWidget>
/** Minimum gap between label and value */
static labelValueGap = 5
declare computedHeight?: number
declare serialize?: boolean
computedHeight?: number
serialize?: boolean
computeLayoutSize?(node: LGraphNode): {
minHeight: number
maxHeight?: number

View File

@@ -66,6 +66,7 @@ LGraph {
"clip_area": undefined,
"clonable": undefined,
"color": undefined,
"comfyClass": undefined,
"console": undefined,
"exec_version": undefined,
"execute_triggered": undefined,
@@ -77,6 +78,7 @@ LGraph {
"id": 1,
"ignore_remove": undefined,
"inputs": [],
"isVirtualNode": undefined,
"last_serialization": {
"id": 1,
},
@@ -138,6 +140,7 @@ LGraph {
"clip_area": undefined,
"clonable": undefined,
"color": undefined,
"comfyClass": undefined,
"console": undefined,
"exec_version": undefined,
"execute_triggered": undefined,
@@ -149,6 +152,7 @@ LGraph {
"id": 1,
"ignore_remove": undefined,
"inputs": [],
"isVirtualNode": undefined,
"last_serialization": {
"id": 1,
},
@@ -211,6 +215,7 @@ LGraph {
"clip_area": undefined,
"clonable": undefined,
"color": undefined,
"comfyClass": undefined,
"console": undefined,
"exec_version": undefined,
"execute_triggered": undefined,
@@ -222,6 +227,7 @@ LGraph {
"id": 1,
"ignore_remove": undefined,
"inputs": [],
"isVirtualNode": undefined,
"last_serialization": {
"id": 1,
},