diff --git a/packages/svelte/src/attachments/index.js b/packages/svelte/src/attachments/index.js index 785a4e096a..514c9433f4 100644 --- a/packages/svelte/src/attachments/index.js +++ b/packages/svelte/src/attachments/index.js @@ -31,6 +31,20 @@ export function createAttachmentKey() { return Symbol(ATTACHMENT_KEY); } +/** + * @template {EventTarget} E + * @template {unknown} T + * @overload + * @param {Action | function(E, T): void | ActionReturn} action The action function + * @param {() => T} fn A function that returns the argument for the action + * @returns {Attachment} + */ +/** + * @template {EventTarget} E + * @overload + * @param {Action | function(E): void | ActionReturn} action The action function + * @returns {Attachment} + */ /** * Converts an Action into an Attachment keeping the same behavior. It's useful if you want to start using * attachments on Components but you have library provided actions. @@ -41,7 +55,7 @@ export function createAttachmentKey() { * @template {EventTarget} E * @template {unknown} T * @param {Action | function(E, T): void | ActionReturn} action The action function - * @param {() => T} [fn] A function that returns the argument for the action + * @param {() => T} fn A function that returns the argument for the action * @returns {Attachment} * @since 5.32 */ diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index 14a04f1f3a..067e04db5b 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -659,18 +659,10 @@ declare module 'svelte/attachments' { * @since 5.29 */ export function createAttachmentKey(): symbol; - /** - * Converts an Action into an Attachment keeping the same behavior. It's useful if you want to start using - * attachments on Components but you have library provided actions. - * - * Note that the second argument, if provided, must be a function that _returns_ the argument to the - * action function, not the argument itself. - * - * @param action The action function - * @param fn A function that returns the argument for the action - * @since 5.32 - */ - export function fromAction(action: Action | ((arg0: E, arg1: T) => void | ActionReturn), fn?: (() => T) | undefined): Attachment; + + export function fromAction(action: Action | ((arg0: E, arg1: T) => void | ActionReturn), fn: () => T): Attachment; + + export function fromAction(action: Action | ((arg0: E) => void | ActionReturn)): Attachment; export {}; }