8000 remove `FromAction` interface by Rich-Harris · Pull Request #15958 · sveltejs/svelte · GitHub
[go: up one dir, main page]

Skip to content

remove FromAction interface #15958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
overload
  • Loading branch information
Rich-Harris committed May 19, 2025
commit 7c2a49e326c0b38a06ec7939c16cf41074eef75f
16 changes: 15 additions & 1 deletion packages/svelte/src/attachments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ export function createAttachmentKey() {
return Symbol(ATTACHMENT_KEY);
}

/**
* @template {EventTarget} E
* @template {unknown} T
* @overload
* @param {Action<E, T> | function(E, T): void | ActionReturn<T>} action The action function
* @param {() => T} fn A function that returns the argument for the action
* @returns {Attachment<E>}
*/
/**
* @template {EventTarget} E
* @overload
* @param {Action<E, void> | function(E): void | ActionReturn<void>} action The action function
* @returns {Attachment<E>}
*/
/**
* 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.
Expand All @@ -41,7 +55,7 @@ export function createAttachmentKey() {
* @template {EventTarget} E
* @template {unknown} T
* @param {Action<E, T> | function(E, T): void | ActionReturn<T>} 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<E>}
* @since 5.32
*/
Expand Down
16 changes: 4 additions & 12 deletions packages/svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,18 +659,10 @@ declare module 'svelte/attachments' {
7344 * @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<E extends EventTarget, T extends unknown>(action: Action<E, T> | ((arg0: E, arg1: T) => void | ActionReturn<T>), fn?: (() => T) | undefined): Attachment<E>;

export function fromAction<E extends EventTarget, T extends unknown>(action: Action<E, T> | ((arg0: E, arg1: T) => void | ActionReturn<T>), fn: () => T): Attachment<E>;

export function fromAction<E extends EventTarget>(action: Action<E, void> | ((arg0: E) => void | ActionReturn<void>)): Attachment<E>;

export {};
}
Expand Down
0