[TS] Enable strict mode (#3136)

This commit is contained in:
Chenlei Hu
2025-03-18 22:57:17 -04:00
committed by GitHub
parent 44edec7ad2
commit a049e9ae2d
64 changed files with 924 additions and 781 deletions

View File

@@ -1,4 +1,3 @@
// @ts-strict-ignore
import Fuse, { FuseSearchOptions, IFuseOptions } from 'fuse.js'
import _ from 'lodash'
@@ -23,6 +22,7 @@ export class FuseSearch<T> {
advancedScoring: boolean = false
) {
this.data = data
// @ts-expect-error fixme ts strict error
this.keys = (options.keys ?? []) as string[]
this.advancedScoring = advancedScoring
const index =
@@ -44,6 +44,7 @@ export class FuseSearch<T> {
const aux = fuseResult
.map((x) => ({
item: x.item,
// @ts-expect-error fixme ts strict error
scores: this.calcAuxScores(query.toLocaleLowerCase(), x.item, x.score)
}))
.sort((a, b) => this.compareAux(a.scores, b.scores))
@@ -54,6 +55,7 @@ export class FuseSearch<T> {
public calcAuxScores(query: string, entry: T, score: number): SearchAuxScore {
let values: string[] = []
if (!this.keys.length) values = [entry as string]
// @ts-expect-error fixme ts strict error
else values = this.keys.map((x) => entry[x])
const scores = values.map((x) => this.calcAuxSingle(query, x, score))
let result = scores.sort(this.compareAux)[0]
@@ -62,7 +64,9 @@ export class FuseSearch<T> {
x.toLocaleLowerCase().includes('deprecated')
)
result[0] += deprecated && result[0] != 0 ? 5 : 0
// @ts-expect-error fixme ts strict error
if (entry['postProcessSearchScores']) {
// @ts-expect-error fixme ts strict error
result = entry['postProcessSearchScores'](result) as SearchAuxScore
}
return result
@@ -155,8 +159,10 @@ export class NodeFilter<FilterOptionT = string> {
}
public getAllNodeOptions(nodeDefs: ComfyNodeDefImpl[]): FilterOptionT[] {
// @ts-expect-error fixme ts strict error
return [
...new Set(
// @ts-expect-error fixme ts strict error
nodeDefs.reduce((acc, nodeDef) => {
return [...acc, ...this.getNodeOptions(nodeDef)]
}, [])