From 3c3351ae53cb7bd98537d827025c84443d2d5866 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Tue, 5 Dec 2023 17:30:55 +0100 Subject: [PATCH 1/3] breaking: stricten types around `depends` and `invalidate` require a `:` when passing a string now closes #9763 --- .changeset/dirty-phones-report.md | 5 +++++ packages/kit/src/exports/public.d.ts | 2 +- packages/kit/src/runtime/app/navigation.js | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/dirty-phones-report.md diff --git a/.changeset/dirty-phones-report.md b/.changeset/dirty-phones-report.md new file mode 100644 index 000000000000..520cccd96b44 --- /dev/null +++ b/.changeset/dirty-phones-report.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': major +--- + +breaking: stricten types around `depends` and `invalidate` to require a `:` when passing a string diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 05fa8d832e2d..4e5e4bce53aa 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -779,7 +779,7 @@ export interface LoadEvent< * * ``` */ - depends(...deps: string[]): void; + depends(...deps: Array<`${string}:${string}`>): void; } export interface NavigationEvent< diff --git a/packages/kit/src/runtime/app/navigation.js b/packages/kit/src/runtime/app/navigation.js index 527a85fa14d7..4aada9db1ad8 100644 --- a/packages/kit/src/runtime/app/navigation.js +++ b/packages/kit/src/runtime/app/navigation.js @@ -44,8 +44,8 @@ export const goto = /* @__PURE__ */ client_method('goto'); * * invalidate((url) => url.pathname === '/path'); * ``` - * @type {(url: string | URL | ((url: URL) => boolean)) => Promise} - * @param {string | URL | ((url: URL) => boolean)} url The invalidated URL + * @type {(url: `${string}:${string}` | URL | ((url: URL) => boolean)) => Promise} + * @param {`${string}:${string}` | URL | ((url: URL) => boolean)} url The invalidated URL * @returns {Promise} */ export const invalidate = /* @__PURE__ */ client_method('invalidate'); From d04483a14d8ce23068cb02609b02e517d3e21e43 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 6 Dec 2023 08:58:32 +0100 Subject: [PATCH 2/3] Update .changeset/dirty-phones-report.md Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- .changeset/dirty-phones-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/dirty-phones-report.md b/.changeset/dirty-phones-report.md index 520cccd96b44..7e44f64d8e1e 100644 --- a/.changeset/dirty-phones-report.md +++ b/.changeset/dirty-phones-report.md @@ -2,4 +2,4 @@ '@sveltejs/kit': major --- -breaking: stricten types around `depends` and `invalidate` to require a `:` when passing a string +breaking: the types for `depends` and `invalidate` now require a `:` when passing a string From 2df43bc1e66e7e83298ebf58108efb307b5df308 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 6 Dec 2023 09:05:08 +0100 Subject: [PATCH 3/3] revert invalidate change --- .changeset/dirty-phones-report.md | 2 +- packages/kit/src/runtime/app/navigation.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/dirty-phones-report.md b/.changeset/dirty-phones-report.md index 7e44f64d8e1e..40b13d4c0e5c 100644 --- a/.changeset/dirty-phones-report.md +++ b/.changeset/dirty-phones-report.md @@ -2,4 +2,4 @@ '@sveltejs/kit': major --- -breaking: the types for `depends` and `invalidate` now require a `:` when passing a string +breaking: the type for `depends` now requires a `:` as part of the string diff --git a/packages/kit/src/runtime/app/navigation.js b/packages/kit/src/runtime/app/navigation.js index 4aada9db1ad8..527a85fa14d7 100644 --- a/packages/kit/src/runtime/app/navigation.js +++ b/packages/kit/src/runtime/app/navigation.js @@ -44,8 +44,8 @@ export const goto = /* @__PURE__ */ client_method('goto'); * * invalidate((url) => url.pathname === '/path'); * ``` - * @type {(url: `${string}:${string}` | URL | ((url: URL) => boolean)) => Promise} - * @param {`${string}:${string}` | URL | ((url: URL) => boolean)} url The invalidated URL + * @type {(url: string | URL | ((url: URL) => boolean)) => Promise} + * @param {string | URL | ((url: URL) => boolean)} url The invalidated URL * @returns {Promise} */ export const invalidate = /* @__PURE__ */ client_method('invalidate');