Skip to content

Commit b5a919e

Browse files
authored
fix: remove useless @ts-ignore and migrate to @ts-expect-error (#293)
* fix: vite primevue/treenode import error * refactor: remove useless @ts-ignore and replace with @ts-expect-error * build(tsconfig): enable incremental to speed up secondary time type check
1 parent 7e669b0 commit b5a919e

31 files changed

+135
-202
lines changed

src/components/sidebar/tabs/NodeLibrarySideBarTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ import Badge from 'primevue/badge'
7171
import ToggleButton from 'primevue/togglebutton'
7272
import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore'
7373
import { computed, ref } from 'vue'
74-
import { TreeNode } from 'primevue/treenode'
74+
import type { TreeNode } from 'primevue/treenode'
7575
import TreePlus from '@/components/primevueOverride/TreePlus.vue'
7676
import NodePreview from '@/components/NodePreview.vue'
7777
import SideBarTabTemplate from '@/components/sidebar/tabs/SideBarTabTemplate.vue'

src/extensions/core/colorPalette.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ app.registerExtension({
437437
* @param {image} String
438438
* @param {clearBackgroundColor} String
439439
*/
440-
// @ts-ignore
440+
// @ts-expect-error
441441
LGraphCanvas.prototype.updateBackground = function (
442442
image,
443443
clearBackgroundColor
@@ -633,12 +633,11 @@ app.registerExtension({
633633
// Sets the colors of node slots and links
634634
if (colorPalette.colors.node_slot) {
635635
Object.assign(
636-
// @ts-ignore
636+
// @ts-expect-error
637637
app.canvas.default_connection_color_byType,
638638
colorPalette.colors.node_slot
639639
)
640640
Object.assign(
641-
// @ts-ignore
642641
LGraphCanvas.link_type_colors,
643642
colorPalette.colors.node_slot
644643
)
@@ -877,7 +876,7 @@ app.registerExtension({
877876
BACKGROUND_IMAGE = base.BACKGROUND_IMAGE
878877
CLEAR_BACKGROUND_COLOR = base.CLEAR_BACKGROUND_COLOR
879878
}
880-
// @ts-ignore
879+
// @ts-expect-error
881880
// litegraph.extensions.js
882881
app.canvas.updateBackground(BACKGROUND_IMAGE, CLEAR_BACKGROUND_COLOR)
883882
}

src/extensions/core/contextMenuFilter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ext = {
77
name: 'Comfy.ContextMenuFilter',
88
init() {
99
const ctxMenu = LiteGraph.ContextMenu
10-
// @ts-ignore
10+
// @ts-expect-error
1111
// TODO Very hacky way to modify Litegraph behaviour. Fix this later.
1212
LiteGraph.ContextMenu = function (values, options) {
1313
const ctx = ctxMenu.call(this, values, options)
@@ -27,7 +27,7 @@ const ext = {
2727

2828
// We must request an animation frame for the current node of the active canvas to update.
2929
requestAnimationFrame(() => {
30-
// @ts-ignore
30+
// @ts-expect-error
3131
const currentNode = LGraphCanvas.active_canvas.current_node
3232
const clickedComboValue = currentNode.widgets
3333
?.filter(

src/extensions/core/groupNode.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ const Workflow = {
1616
isInUseGroupNode(name) {
1717
const id = `workflow/${name}`
1818
// Check if lready registered/in use in this workflow
19-
// @ts-ignore
2019
if (app.graph.extra?.groupNodes?.[name]) {
21-
// @ts-ignore
20+
// @ts-expect-error
2221
if (app.graph._nodes.find((n) => n.type === id)) {
2322
return Workflow.InUse.InWorkflow
2423
} else {
@@ -28,9 +27,7 @@ const Workflow = {
2827
return Workflow.InUse.Free
2928
},
3029
storeGroupNode(name, data) {
31-
// @ts-ignore
3230
let extra = app.graph.extra
33-
// @ts-ignore
3431
if (!extra) app.graph.extra = extra = {}
3532
let groupNodes = extra.groupNodes
3633
if (!groupNodes) extra.groupNodes = groupNodes = {}
@@ -133,7 +130,7 @@ class GroupNodeBuilder {
133130
// Use the built in copyToClipboard function to generate the node data we need
134131
const backup = localStorage.getItem('litegrapheditor_clipboard')
135132
try {
136-
// @ts-ignore
133+
// @ts-expect-error
137134
// TODO Figure out if copyToClipboard is really taking this param
138135
app.canvas.copyToClipboard(this.nodes)
139136
const config = JSON.parse(
@@ -328,7 +325,6 @@ export class GroupNodeConfig {
328325
null,
329326
widget
330327
)
331-
// @ts-ignore
332328
config = res?.customConfig ?? config
333329
}
334330
}
@@ -352,7 +348,7 @@ export class GroupNodeConfig {
352348
}
353349
}
354350

355-
// @ts-ignore
351+
// @ts-expect-error
356352
config.forceInput = true
357353
return {
358354
input: {
@@ -743,7 +739,7 @@ export class GroupNodeHandler {
743739
let link = app.graph.links[linkId]
744740

745741
// Use the outer link, but update the target to the inner node
746-
// @ts-ignore
742+
// @ts-expect-error
747743
// TODO: Fix this
748744
link = {
749745
...link,
@@ -797,7 +793,7 @@ export class GroupNodeHandler {
797793
this.groupData.nodeData.nodes.map((n, i) => {
798794
const innerNode = LiteGraph.createNode(n.type)
799795
innerNode.configure(n)
800-
// @ts-ignore
796+
// @ts-expect-error
801797
innerNode.id = `${this.node.id}:${i}`
802798
return innerNode
803799
})
@@ -1411,9 +1407,7 @@ function addConvertToGroupOptions() {
14111407
}
14121408

14131409
// Add to canvas
1414-
// @ts-ignore
14151410
const getCanvasMenuOptions = LGraphCanvas.prototype.getCanvasMenuOptions
1416-
// @ts-ignore
14171411
LGraphCanvas.prototype.getCanvasMenuOptions = function () {
14181412
const options = getCanvasMenuOptions.apply(this, arguments)
14191413
const index =
@@ -1424,9 +1418,7 @@ function addConvertToGroupOptions() {
14241418
}
14251419

14261420
// Add to nodes
1427-
// @ts-ignore
14281421
const getNodeMenuOptions = LGraphCanvas.prototype.getNodeMenuOptions
1429-
// @ts-ignore
14301422
LGraphCanvas.prototype.getNodeMenuOptions = function (node) {
14311423
const options = getNodeMenuOptions.apply(this, arguments)
14321424
if (!GroupNodeHandler.isGroupNode(node)) {

src/extensions/core/groupNodeManage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ export class ManageGroupDialog extends ComfyDialog<HTMLDialogElement> {
388388
'button.comfy-btn',
389389
{
390390
onclick: (e) => {
391-
// @ts-ignore
391+
// @ts-expect-error
392392
const node = app.graph._nodes.find(
393393
(n) => n.type === 'workflow/' + this.selectedGroup
394394
)
@@ -470,7 +470,7 @@ export class ManageGroupDialog extends ComfyDialog<HTMLDialogElement> {
470470
types[g] = type
471471

472472
if (!nodesByType) {
473-
// @ts-ignore
473+
// @ts-expect-error
474474
nodesByType = app.graph._nodes.reduce((p, n) => {
475475
p[n.type] ??= []
476476
p[n.type].push(n)

src/extensions/core/groupOptions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ function addNodesToGroup(group, nodes = []) {
6464
app.registerExtension({
6565
name: 'Comfy.GroupOptions',
6666
setup() {
67-
// @ts-ignore
6867
const orig = LGraphCanvas.prototype.getCanvasMenuOptions
6968
// graph_mouse
70-
// @ts-ignore
7169
LGraphCanvas.prototype.getCanvasMenuOptions = function () {
7270
const options = orig.apply(this, arguments)
7371
const group = this.graph.getGroupOnPos(
@@ -79,7 +77,7 @@ app.registerExtension({
7977
content: 'Add Group For Selected Nodes',
8078
disabled: !Object.keys(app.canvas.selected_nodes || {}).length,
8179
callback: () => {
82-
// @ts-ignore
80+
// @ts-expect-error
8381
var group = new LiteGraph.LGraphGroup()
8482
addNodesToGroup(group, this.selected_nodes)
8583
app.canvas.graph.add(group)

src/extensions/core/invertMenuScrolling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ app.registerExtension({
99
init() {
1010
const ctxMenu = LiteGraph.ContextMenu
1111
const replace = () => {
12-
// @ts-ignore
12+
// @ts-expect-error
1313
LiteGraph.ContextMenu = function (values, options) {
1414
options = options || {}
1515
if (options.scroll_speed) {

src/extensions/core/linkRenderMode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ext = {
99
name: 'Link Render Mode',
1010
defaultValue: 2,
1111
type: 'combo',
12-
// @ts-ignore
12+
// @ts-expect-error
1313
options: [...LiteGraph.LINK_RENDER_MODES, 'Hidden'].map((m, i) => ({
1414
value: i,
1515
text: m,

src/extensions/core/maskeditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ class MaskEditorDialog extends ComfyDialog {
252252
brush.style.outline = '1px dashed black'
253253
brush.style.boxShadow = '0 0 0 1px white'
254254
brush.style.borderRadius = '50%'
255-
// @ts-ignore
255+
// @ts-expect-error
256256
brush.style.MozBorderRadius = '50%'
257-
// @ts-ignore
257+
// @ts-expect-error
258258
brush.style.WebkitBorderRadius = '50%'
259259
brush.style.position = 'absolute'
260260
brush.style.zIndex = '8889'

src/extensions/core/nodeTemplates.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,7 @@ app.registerExtension({
359359
localStorage.setItem('litegrapheditor_clipboard', old)
360360
}
361361

362-
// @ts-ignore
363362
const orig = LGraphCanvas.prototype.getCanvasMenuOptions
364-
// @ts-ignore
365363
LGraphCanvas.prototype.getCanvasMenuOptions = function () {
366364
const options = orig.apply(this, arguments)
367365

@@ -380,20 +378,20 @@ app.registerExtension({
380378
const nodeIds = Object.keys(app.canvas.selected_nodes)
381379
for (let i = 0; i < nodeIds.length; i++) {
382380
const node = app.graph.getNodeById(Number.parseInt(nodeIds[i]))
383-
// @ts-ignore
381+
// @ts-expect-error
384382
const nodeData = node?.constructor.nodeData
385383

386384
let groupData = GroupNodeHandler.getGroupData(node)
387385
if (groupData) {
388386
groupData = groupData.nodeData
389-
// @ts-ignore
387+
// @ts-expect-error
390388
if (!data.groupNodes) {
391-
// @ts-ignore
389+
// @ts-expect-error
392390
data.groupNodes = {}
393391
}
394-
// @ts-ignore
392+
// @ts-expect-error
395393
data.groupNodes[nodeData.name] = groupData
396-
// @ts-ignore
394+
// @ts-expect-error
397395
data.nodes[i].type = nodeData.name
398396
}
399397
}

0 commit comments

Comments
 (0)