diff --git a/web/app/components/app/configuration/config/automatic/instruction-editor.tsx b/web/app/components/app/configuration/config/automatic/instruction-editor.tsx index c4f0a906be..5eb1fe12be 100644 --- a/web/app/components/app/configuration/config/automatic/instruction-editor.tsx +++ b/web/app/components/app/configuration/config/automatic/instruction-editor.tsx @@ -61,7 +61,7 @@ const InstructionEditor: FC = ({ ) const handleInsertVariable = () => { - eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId: editorKey } as any) + eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId: editorKey }) } return ( diff --git a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx index 37451149c5..a6ae29412c 100644 --- a/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx +++ b/web/app/components/workflow/nodes/_base/components/prompt/editor.tsx @@ -157,7 +157,7 @@ const Editor: FC = ({ const handleInsertVariable = () => { setFocus() - eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId } as any) + eventEmitter?.emit({ type: PROMPT_EDITOR_INSERT_QUICKLY, instanceId }) } const getVarType = useWorkflowVariableType() diff --git a/web/app/components/workflow/variable-inspect/right.tsx b/web/app/components/workflow/variable-inspect/right.tsx index 7befbb1aa0..7cc6baf9a4 100644 --- a/web/app/components/workflow/variable-inspect/right.tsx +++ b/web/app/components/workflow/variable-inspect/right.tsx @@ -143,7 +143,7 @@ const Right: FC = ({ type: PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER, instanceId: `${nodeId}-chat-workflow-llm-prompt-editor`, payload: res.modified, - } as any) + }) handleHidePromptGenerator() }, [setInputs, blockType, nodeId, node?.data, handleHidePromptGenerator]) diff --git a/web/app/components/workflow/variable-inspect/trigger.tsx b/web/app/components/workflow/variable-inspect/trigger.tsx index d7fe0bcbb9..f5a833f456 100644 --- a/web/app/components/workflow/variable-inspect/trigger.tsx +++ b/web/app/components/workflow/variable-inspect/trigger.tsx @@ -49,7 +49,7 @@ const VariableInspectTrigger: FC = () => { const handleStop = () => { eventEmitter?.emit({ type: EVENT_WORKFLOW_STOP, - } as any) + }) } const handleClearAll = () => { diff --git a/web/app/components/workflow/variable-inspect/variables-tab.tsx b/web/app/components/workflow/variable-inspect/variables-tab.tsx index f71c379af1..74792e41c8 100644 --- a/web/app/components/workflow/variable-inspect/variables-tab.tsx +++ b/web/app/components/workflow/variable-inspect/variables-tab.tsx @@ -127,8 +127,7 @@ const VariablesTab: FC = (headerProps) => { const { eventEmitter } = useEventEmitterContextContext() const onStopListening = useCallback(() => { - // eslint-disable-next-line ts/no-explicit-any -- EventEmitter is typed as string but project-wide convention passes { type } objects - eventEmitter?.emit({ type: EVENT_WORKFLOW_STOP } as any) + eventEmitter?.emit({ type: EVENT_WORKFLOW_STOP }) }, [eventEmitter]) useEffect(() => { diff --git a/web/context/event-emitter.tsx b/web/context/event-emitter.tsx index 61a605cabf..ab311bed02 100644 --- a/web/context/event-emitter.tsx +++ b/web/context/event-emitter.tsx @@ -4,7 +4,9 @@ import type { EventEmitter } from 'ahooks/lib/useEventEmitter' import { useEventEmitter } from 'ahooks' import { createContext, useContext } from 'use-context-selector' -const EventEmitterContext = createContext<{ eventEmitter: EventEmitter | null }>({ +export type EventPayload = string | ({ type: string } & Record) + +const EventEmitterContext = createContext<{ eventEmitter: EventEmitter | null }>({ eventEmitter: null, }) @@ -16,7 +18,7 @@ type EventEmitterContextProviderProps = { export const EventEmitterContextProvider = ({ children, }: EventEmitterContextProviderProps) => { - const eventEmitter = useEventEmitter() + const eventEmitter = useEventEmitter() return (