diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 8e12f9f0eebb..fa45e190af79 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -11,6 +11,7 @@ export { hasContext, tick, createEventDispatcher, + Action, SvelteComponentDev as SvelteComponent, SvelteComponentTyped } from 'svelte/internal'; diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 287c16b5fc5d..cd13092a79a0 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -732,3 +732,20 @@ export function get_custom_elements_slots(element: HTMLElement) { }); return result; } + + +type ActionWithParams = ( + node: Node, + options: Params +) => { + update?: (params: Params) => void + destroy?: () => void +} + +type ActionWithoutParams = (node: Node) => { + destroy?: () => void +} + +export type Action = void extends Params + ? ActionWithoutParams + : ActionWithParams