diff --git a/src/runtime/action/index.ts b/src/runtime/action/index.ts index d7cbf04b12..3469ecbb71 100644 --- a/src/runtime/action/index.ts +++ b/src/runtime/action/index.ts @@ -17,10 +17,14 @@ * * Docs: https://svelte.dev/docs#template-syntax-element-directives-use-action */ -export interface ActionReturn { - update?: (parameter: Parameter) => void; - destroy?: () => void; -} +export type ActionReturn = void extends Parameter + ? { + destroy?: () => void; + } + : { + update?: (parameter: Parameter) => void; + destroy?: () => void; + } /** * Actions are functions that are called when an element is created. @@ -37,6 +41,7 @@ export interface ActionReturn { * * Docs: https://svelte.dev/docs#template-syntax-element-directives-use-action */ -export interface Action { - (node: Node, parameter?: Parameter): void | ActionReturn; -} +export type Action = + void extends Parameter + ? (node: Node) => void | ActionReturn + : (node: Node, parameter: Parameter) => void | ActionReturn;