mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-14 09:27:41 +00:00
feat: No Explicit Any (#8601)
## Summary - Add `typescript/no-explicit-any` rule to `.oxlintrc.json` to enforce no explicit `any` types - Fix all 40 instances of explicit `any` throughout the codebase - Improve type safety with proper TypeScript types ## Changes Made ### Configuration - Added `typescript/no-explicit-any` rule to `.oxlintrc.json` ### Type Fixes - Replaced `any` with `unknown` for truly unknown types - Updated generic type parameters to use `unknown` defaults instead of `any` - Fixed method `this` parameters to avoid variance issues - Updated component props to match new generic types - Fixed test mocks to use proper type assertions ### Key Files Modified - `src/types/treeExplorerTypes.ts`: Updated TreeExplorerNode interface generics - `src/platform/settings/types.ts`: Fixed SettingParams generic default - `src/lib/litegraph/src/LGraph.ts`: Fixed ParamsArray type constraint - `src/extensions/core/electronAdapter.ts`: Fixed onChange callbacks - `src/views/GraphView.vue`: Added proper type imports - Multiple test files: Fixed type assertions and mocks ## Test Plan - [x] All lint checks pass (`pnpm lint`) - [x] TypeScript compilation succeeds (`pnpm typecheck`) - [x] Pre-commit hooks pass - [x] No regression in functionality ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8601-feat-add-typescript-no-explicit-any-rule-and-fix-all-instances-2fd6d73d365081fd9beef75d5a6daf5b) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Alexander Brown <drjkl@comfy.org>
This commit is contained in:
committed by
GitHub
parent
92b7437d86
commit
4fc1d2ef5b
@@ -36,7 +36,7 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts" generic="T">
|
||||
import { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview'
|
||||
import Badge from 'primevue/badge'
|
||||
import { computed, inject, ref } from 'vue'
|
||||
@@ -53,17 +53,17 @@ import type {
|
||||
} from '@/types/treeExplorerTypes'
|
||||
|
||||
const props = defineProps<{
|
||||
node: RenderedTreeExplorerNode
|
||||
node: RenderedTreeExplorerNode<T>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(
|
||||
e: 'itemDropped',
|
||||
node: RenderedTreeExplorerNode,
|
||||
data: RenderedTreeExplorerNode
|
||||
node: RenderedTreeExplorerNode<T>,
|
||||
data: RenderedTreeExplorerNode<T>
|
||||
): void
|
||||
(e: 'dragStart', node: RenderedTreeExplorerNode): void
|
||||
(e: 'dragEnd', node: RenderedTreeExplorerNode): void
|
||||
(e: 'dragStart', node: RenderedTreeExplorerNode<T>): void
|
||||
(e: 'dragEnd', node: RenderedTreeExplorerNode<T>): void
|
||||
}>()
|
||||
|
||||
const nodeBadgeText = computed<string>(() => {
|
||||
@@ -80,7 +80,7 @@ const showNodeBadgeText = computed<boolean>(() => nodeBadgeText.value !== '')
|
||||
const isEditing = computed<boolean>(() => props.node.isEditingLabel ?? false)
|
||||
const handleEditLabel = inject(InjectKeyHandleEditLabelFunction)
|
||||
const handleRename = (newName: string) => {
|
||||
handleEditLabel?.(props.node, newName)
|
||||
handleEditLabel?.(props.node as RenderedTreeExplorerNode, newName)
|
||||
}
|
||||
|
||||
const container = ref<HTMLElement | null>(null)
|
||||
@@ -117,9 +117,13 @@ if (props.node.droppable) {
|
||||
onDrop: async (event) => {
|
||||
const dndData = event.source.data as TreeExplorerDragAndDropData
|
||||
if (dndData.type === 'tree-explorer-node') {
|
||||
await props.node.handleDrop?.(dndData)
|
||||
await props.node.handleDrop?.(dndData as TreeExplorerDragAndDropData<T>)
|
||||
canDrop.value = false
|
||||
emit('itemDropped', props.node, dndData.data)
|
||||
emit(
|
||||
'itemDropped',
|
||||
props.node,
|
||||
dndData.data as RenderedTreeExplorerNode<T>
|
||||
)
|
||||
}
|
||||
},
|
||||
onDragEnter: (event) => {
|
||||
|
||||
Reference in New Issue
Block a user