Repository: sveltejs/kit
Pull request #8149 (2022-12-14 13:09:46)

[fix] remove obsolete generated types correctly
### Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [ ] 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


changeset-bot[bot]: ###  🦋  Changeset detected

Latest commit: 7f52a51b2da9418586caaa5e34d633620ed9d1f6

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name          | Type  |
| ------------- | ----- |
| @sveltejs/kit | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/sveltejs/kit/new/types-gen-fix?filename=.changeset/tidy-experts-tickle.md&value=---%0A%22%40sveltejs%2Fkit%22%3A%20patch%0A%22prerendering-test-ssr-false%22%3A%20patch%0A---%0A%0A%5Bfix%5D%20remove%20obsolete%20generated%20types%20correctly%0A)



Patch:
diff --git a/.changeset/fresh-files-study.md b/.changeset/fresh-files-study.md
new file mode 100644
index 000000000..0b5ec64a9
--- /dev/null
+++ b/.changeset/fresh-files-study.md
@@ -0,0 +1,5 @@
+---
+'@sveltejs/kit': patch
+---
+
+[fix] remove obsolete generated types correctly
diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js
index 2e3eab2c8..83cb0e7e8 100644
--- a/packages/kit/src/core/sync/write_types/index.js
+++ b/packages/kit/src/core/sync/write_types/index.js
@@ -49,7 +49,7 @@ export async function write_all_types(config, manifest_data) {
 		for (const file of walk(types_dir)) {
 			const dir = path.dirname(file);
 			if (!expected_directories.has(dir)) {
-				rimraf(file);
+				rimraf(path.join(types_dir, file));
 			}
 		}
 	}
diff --git a/packages/kit/src/utils/filesystem.js b/packages/kit/src/utils/filesystem.js
index 1296bd0d2..f53b10452 100644
--- a/packages/kit/src/utils/filesystem.js
+++ b/packages/kit/src/utils/filesystem.js
@@ -83,6 +83,7 @@ export function copy(source, target, opts = {}) {
  * Get a list of all files in a directory
  * @param {string} cwd - the directory to walk
  * @param {boolean} [dirs] - whether to include directories in the result
+ * @returns {string[]} a list of all found files (and possibly directories) relative to `cwd`
  */
 export function walk(cwd, dirs = false) {
 	/** @type {string[]} */


Test patch:
diff --git a/packages/kit/test/prerendering/ssr-false/package.json b/packages/kit/test/prerendering/ssr-false/package.json
index 0e42986ca..5e73df540 100644
--- a/packages/kit/test/prerendering/ssr-false/package.json
+++ b/packages/kit/test/prerendering/ssr-false/package.json
@@ -6,6 +6,7 @@
 		"dev": "vite dev",
 		"build": "vite build",
 		"preview": "vite preview",
+		"check": "svelte-kit sync && tsc && svelte-check",
 		"test": "svelte-kit sync && pnpm build && uvu test"
 	},
 	"devDependencies": {
diff --git a/packages/kit/test/prerendering/ssr-false/src/routes/not-prerenderable/+page.server.js b/packages/kit/test/prerendering/ssr-false/src/routes/not-prerenderable/+page.server.js
index 576d6d28b..0e3c31134 100644
--- a/packages/kit/test/prerendering/ssr-false/src/routes/not-prerenderable/+page.server.js
+++ b/packages/kit/test/prerendering/ssr-false/src/routes/not-prerenderable/+page.server.js
@@ -1,1 +1,3 @@
-export const actions = {};
+export const actions = {
+	default: () => {}
+};