fix(services): remove 8 @ts-expect-error suppressions from litegraphService

Amp-Thread-ID: https://ampcode.com/threads/T-019bafa8-5813-717a-89bf-1ba8b4c4faff
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
DrJKL
2026-01-11 17:01:44 -08:00
parent 45f99a8130
commit e9e02c2c2a
2 changed files with 14 additions and 17 deletions

View File

@@ -618,7 +618,7 @@ export class LGraphNode
): void
onDeselected?(this: LGraphNode): void
onKeyUp?(this: LGraphNode, e: KeyboardEvent): void
onKeyDown?(this: LGraphNode, e: KeyboardEvent): void
onKeyDown?(this: LGraphNode, e: KeyboardEvent): boolean | void
onSelected?(this: LGraphNode): void
getExtraMenuOptions?(
this: LGraphNode,

View File

@@ -772,33 +772,29 @@ export const useLitegraphService = () => {
const origNodeOnKeyDown = node.prototype.onKeyDown
node.prototype.onKeyDown = function (e) {
// @ts-expect-error fixme ts strict error
if (origNodeOnKeyDown && origNodeOnKeyDown.apply(this, e) === false) {
if (origNodeOnKeyDown?.call(this, e) === false) {
return false
}
if (this.flags.collapsed || !this.imgs || this.imageIndex === null) {
if (this.flags.collapsed || !this.imgs || this.imageIndex == null) {
return
}
let handled = false
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
let imageIndex = this.imageIndex
if (e.key === 'ArrowLeft') {
// @ts-expect-error fixme ts strict error
this.imageIndex -= 1
imageIndex -= 1
} else if (e.key === 'ArrowRight') {
// @ts-expect-error fixme ts strict error
this.imageIndex += 1
imageIndex += 1
}
// @ts-expect-error fixme ts strict error
this.imageIndex %= this.imgs.length
imageIndex %= this.imgs.length
// @ts-expect-error fixme ts strict error
if (this.imageIndex < 0) {
// @ts-expect-error fixme ts strict error
this.imageIndex = this.imgs.length + this.imageIndex
if (imageIndex < 0) {
imageIndex = this.imgs.length + imageIndex
}
this.imageIndex = imageIndex
handled = true
} else if (e.key === 'Escape') {
this.imageIndex = null
@@ -843,12 +839,13 @@ export const useLitegraphService = () => {
nodeDef.display_name,
options
)
if (!node) {
throw new Error(`Failed to create node: ${nodeDef.name}`)
}
const graph = useWorkflowStore().activeSubgraph ?? app.graph
const graph = useWorkflowStore().activeSubgraph ?? app.rootGraph
// @ts-expect-error fixme ts strict error
graph.add(node)
// @ts-expect-error fixme ts strict error
return node
}