diff --git a/.changeset/tall-dots-agree.md b/.changeset/tall-dots-agree.md new file mode 100644 index 000000000000..162dd854cf9e --- /dev/null +++ b/.changeset/tall-dots-agree.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: amend onNavigate type diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 283cc0473a30..6db8e241d246 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -1608,7 +1608,7 @@ export function beforeNavigate(callback) { * If a function (or a `Promise` that resolves to a function) is returned from the callback, it will be called once the DOM has updated. * * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted. - * @param {(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise} callback + * @param {(navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>} callback * @returns {void} */ export function onNavigate(callback) { diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index f9945914e31e..a983b4433561 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -1981,7 +1981,7 @@ declare module '$app/navigation' { * * `onNavigate` must be called during a component initialization. It remains active as long as the component is mounted. * */ - export function onNavigate(callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise): void; + export function onNavigate(callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise<(() => void) | void>): void; /** * If called when the page is being updated following a navigation (in `onMount` or `afterNavigate` or an action, for example), this disables SvelteKit's built-in scroll handling. * This is generally discouraged, since it breaks user expectations.