Skip to content

fix: update onMount type definition to prevent async function return #8136

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

2 changes: 1 addition & 1 deletion src/runtime/internal/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function beforeUpdate(fn: () => any) {
*
* https://svelte.dev/docs#run-time-svelte-onmount
*/
export function onMount(fn: () => any) {
export function onMount<T>(fn: (() => T extends Promise<void> ? T : T extends Promise<unknown> ? never : T)): void {
get_current_component().$$.on_mount.push(fn);
}

Expand Down