Skip to content

Commit cfadb31

Browse files
fix(ui): ts issues
1 parent b5cadd9 commit cfadb31

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

invokeai/frontend/web/src/features/dnd/DndDropTarget.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ export const DndDropTarget = memo(<T extends AnyDndTarget>(props: Props<T>) => {
8989
dropTargetForElements({
9090
element,
9191
canDrop: ({ source }) => {
92-
return dndTarget.isValid({ sourceData: source.data, targetData: dndTargetData, dispatch, getState });
92+
// TS cannot infer `dndTargetData` but we've just checked it.
93+
// TODO(psyche): Figure out how to satisfy TS.
94+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
95+
const arg = { sourceData: source.data, targetData: dndTargetData, dispatch, getState } as any;
96+
return dndTarget.isValid(arg);
9397
},
9498
onDragEnter: () => {
9599
setDndState('over');
@@ -101,7 +105,11 @@ export const DndDropTarget = memo(<T extends AnyDndTarget>(props: Props<T>) => {
101105
}),
102106
monitorForElements({
103107
canMonitor: ({ source }) => {
104-
return dndTarget.isValid({ sourceData: source.data, targetData: dndTargetData, dispatch, getState });
108+
// TS cannot infer `dndTargetData` but we've just checked it.
109+
// TODO(psyche): Figure out how to satisfy TS.
110+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
111+
const arg = { sourceData: source.data, targetData: dndTargetData, dispatch, getState } as any;
112+
return dndTarget.isValid(arg);
105113
},
106114
onDragStart: () => {
107115
setDndOrigin('element');

invokeai/frontend/web/src/features/dnd/dnd.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,10 @@ export const isValidDrop = (arg: {
475475
if (!dndTarget.typeGuard(arg.targetData)) {
476476
continue;
477477
}
478-
// TS cannot infer `targetData` but we've just checked it. This is safe.
478+
// TS cannot infer `arg.targetData` but we've just checked it.
479+
// TODO(psyche): Figure out how to satisfy TS.
479480
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
480-
if (!dndTarget.isValid(arg)) {
481+
if (!dndTarget.isValid(arg as any)) {
481482
return true;
482483
}
483484
}

invokeai/frontend/web/src/features/dnd/useDndMonitor.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,20 @@ export const useDndMonitor = () => {
4444
if (!dndTarget.typeGuard(targetData)) {
4545
continue;
4646
}
47-
// TS cannot infer `targetData` but we've just checked it. This is safe.
47+
const arg = { sourceData, targetData, dispatch, getState };
48+
// TS cannot infer `arg.targetData` but we've just checked it.
49+
// TODO(psyche): Figure out how to satisfy TS.
4850
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
49-
const arg = { sourceData, targetData: targetData as any, dispatch, getState };
50-
if (!dndTarget.isValid(arg)) {
51+
if (!dndTarget.isValid(arg as any)) {
5152
continue;
5253
}
5354

5455
log.debug(parseify({ sourceData, targetData }), 'Handling dnd drop');
55-
dndTarget.handler(arg);
56+
57+
// TS cannot infer `arg.targetData` but we've just checked it.
58+
// TODO(psyche): Figure out how to satisfy TS.
59+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
60+
dndTarget.handler(arg as any);
5661
return;
5762
}
5863

0 commit comments

Comments
 (0)