fix: improve createRawSnippet types with cleanup type (#12894)

* fix: improve createRawSnippet types

Add cleanup type to return value of setup function

* changeset

---------

Co-authored-by: Rich Harris <hello@rich-harris.dev>
pull/12897/head
TOMIKAWA Sotaro 1 year ago committed by GitHub
parent 7eabce8c96
commit b41300d58a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: add cleanup function signature to `createRawSnippet`

@ -72,7 +72,7 @@ export function wrap_snippet(component, fn) {
* @template {unknown[]} Params
* @param {(...params: Getters<Params>) => {
* render: () => string
* setup?: (element: Element) => void
* setup?: (element: Element) => void | (() => void)
* }} fn
* @returns {Snippet<Params>}
*/

@ -7,7 +7,7 @@
* @template {unknown[]} Params
* @param {(...params: Getters<Params>) => {
* render: () => string
* setup?: (element: Element) => void
* setup?: (element: Element) => void | (() => void)
* }} fn
* @returns {Snippet<Params>}
*/

@ -378,7 +378,7 @@ declare module 'svelte' {
* */
export function createRawSnippet<Params extends unknown[]>(fn: (...params: Getters<Params>) => {
render: () => string;
setup?: (element: Element) => void;
setup?: (element: Element) => void | (() => void);
}): Snippet<Params>;
/** Anything except a function */
type NotFunction<T> = T extends Function ? never : T;

Loading…
Cancel
Save