Repository: sveltejs/kit (js)

Issue:
Spurious prop warnings with `+page.svelte` files
### Describe the bug

On each route not using a `load` function, the console has

```
[Warning] <Page> was created with unknown prop 'data' (+page.svelte, line ...)
[Warning] <Page> was created with unknown prop 'errors' (+page.svelte, line ...)
```

These can be removed with the boilerplate

```
export let data;
export let errors;
```

in the `+page.svelte` files for those routes, but ideally the warnings would not be present unless the route has an associated `load` function.


### Reproduction

Launch a SvelteKit app that includes routes which do not explicitly accept `data` or `errors` and check the console.

### Logs

_No response_

### System Info

```shell
System:
    OS: macOS 12.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 25.14 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.4.0 - ~/Library/pnpm/node
    npm: 8.12.1 - ~/Library/pnpm/npm
  Browsers:
    Safari: 15.6
  npmPackages:
    @sveltejs/adapter-static: 1.0.0-next.38 => 1.0.0-next.38 
    @sveltejs/kit: next => 1.0.0-next.411 
    svelte: ^3.49.0 => 3.49.0 
    vite: ^3.0.8 => 3.0.8
```


### Severity

annoyance

### Additional Information

_No response_

Pull request:
[fix] silence prop warnings
Fixes #5980
This could result in false negatives but the probability for that is minimal and not seing the warning sometimes is better than seing the warning without being able to do anything about it

### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it.

### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm lint` and `pnpm check`

### Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. All changesets should be `patch` until SvelteKit 1.0


Patch:
diff --git a/.changeset/funny-cycles-travel.md b/.changeset/funny-cycles-travel.md
new file mode 100644
index 000000000..80f8a991c
--- /dev/null
+++ b/.changeset/funny-cycles-travel.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[fix] update current.url on hashchange
diff --git a/.changeset/gorgeous-flowers-doubt.md b/.changeset/gorgeous-flowers-doubt.md
new file mode 100644
index 000000000..2bc67bc5d
--- /dev/null
+++ b/.changeset/gorgeous-flowers-doubt.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[fix] silence prop warnings
diff --git a/.changeset/immaculate-error-handler.md b/.changeset/immaculate-error-handler.md
new file mode 100644
index 000000000..bc16312ba
--- /dev/null
+++ b/.changeset/immaculate-error-handler.md
@@ -0,0 +1,6 @@
+---
+'@sveltejs/adapter-vercel': patch
+---
+
+Ignore warnings when traced file fails to parse
+
diff --git a/packages/adapter-vercel/index.js b/packages/adapter-vercel/index.js
index 37027c836..071d025e7 100644
--- a/packages/adapter-vercel/index.js
+++ b/packages/adapter-vercel/index.js
@@ -308,6 +308,11 @@ async function create_function_bundle(builder, entry, dir, runtime) {
 		// pending https://github.com/vercel/nft/issues/284
 		if (error.message.startsWith('Failed to resolve dependency node:')) return;
 
+		// parse errors are likely not js and can safely be ignored,
+		// such as this html file in "main" meant for nw instead of node:
+		// https://github.com/vercel/nft/issues/311
+		if (error.message.startsWith('Failed to parse')) return;
+
 		if (error.message.startsWith('Failed to resolve dependency')) {
 			const match = /Cannot find module '(.+?)' loaded from (.+)/;
 			const [, module, importer] = match.exec(error.message);
diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js
index 09be6d707..c6447c09a 100644
--- a/packages/kit/src/runtime/client/client.js
+++ b/packages/kit/src/runtime/client/client.js
@@ -43,6 +43,7 @@ function update_scroll_positions(index) {
 	scroll_positions[index] = scroll_state();
 }
 
+// TODO remove for 1.0
 /** @type {Record<string, true>} */
 let warned_about_attributes = {};
 
@@ -1321,10 +1322,12 @@ export function create_client({ target, base, trailing_slash }) {
 				if (hash !== undefined && base === location.href.split('#')[0]) {
 					// set this flag to distinguish between navigations triggered by
 					// clicking a hash link and those triggered by popstate
+					// TODO why not update history here directly?
 					hash_navigating = true;
 
 					update_scroll_positions(current_history_index);
 
+					current.url = url;
 					stores.page.set({ ...page, url });
 					stores.page.notify();
 
@@ -1545,25 +1548,26 @@ function add_url_properties(type, target) {
 
 function pre_update() {
 	if (__SVELTEKIT_DEV__) {
-		// Nasty hack to silence harmless warnings the user can do nothing about
-		const warn = console.warn;
-		console.warn = (...args) => {
-			if (
-				args.length === 1 &&
-				/<(Layout|Page)(_[\w$]+)?> was created (with unknown|without expected) prop '(data|form)'/.test(
-					args[0]
-				)
-			) {
-				return;
-			}
-			warn(...args);
-		};
-
 		return () => {
-			tick().then(() => (console.warn = warn));
 			check_for_removed_attributes();
 		};
 	}
 
 	return () => {};
 }
+
+if (__SVELTEKIT_DEV__) {
+	// Nasty hack to silence harmless warnings the user can do nothing about
+	const warn = console.warn;
+	console.warn = (...args) => {
+		if (
+			args.length === 1 &&
+			/<(Layout|Page)(_[\w$]+)?> was created (with unknown|without expected) prop '(data|form)'/.test(
+				args[0]
+			)
+		) {
+			return;
+		}
+		warn(...args);
+	};
+}


Test patch:
diff --git a/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte b/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte
index 4a20ec56a..630589a9d 100644
--- a/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte
+++ b/packages/kit/test/apps/basics/src/routes/routing/hashes/pagestore/+page.svelte
@@ -17,5 +17,6 @@
 <h1 id="window-hash">{hash}</h1>
 <h1 id="page-url-hash">{$page.url.hash}</h1>
 
-<a href="#target">Nav to #ing with anchor tag</a>
+<a href="#target">Nav to hash</a>
+<a href="/routing/hashes/pagestore">Nav to page</a>
 <div id="target">Target</div>
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index 1c1237820..d581e34ed 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -551,6 +551,9 @@ test.describe('Routing', () => {
 		await page.click('[href="#target"]');
 		expect(await page.textContent('#window-hash')).toBe('#target');
 		expect(await page.textContent('#page-url-hash')).toBe('#target');
+		await page.click('[href="/routing/hashes/pagestore"]');
+		await expect(page.locator('#window-hash')).toHaveText('#target'); // hashchange doesn't fire for these
+		await expect(page.locator('#page-url-hash')).toHaveText('');
 	});
 
 	test('does not normalize external path', async ({ page }) => {