Repository navigation
fix: stop deleting the root route $types.d.ts on every sync run - #17489
Open
CloudCorpRecords wants to merge 3 commits into
Open
CloudCorpRecords wants to merge 3 commits into
CloudCorpRecords wants to merge 3 commits into
Conversation
Fixes sveltejs#17465. The expected_directories set was keyed with a trailing slash for the root route (path.posix.join(routes_dir, '/')), while path.posix.dirname never produces one, so the root $types.d.ts was treated as surplus and deleted on every sync. Strip the trailing slash so the comparison matches. Adds a regression test that runs write_all_types twice and asserts the root $types.d.ts is never passed to rmSync on the second run, plus a changeset. Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/3ccbd1155c9358a825ce8726306c0e0391cd743bOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: 3ccbd11 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Fixes the lint-all failure (oxfmt --check flagged the spec file). Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
Fixes tsc-native check (TS7034/TS7005): the mock-recording array had an implicit any[] type. Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
CloudCorpRecords
force-pushed
the
fix/root-types-sync-delete-17465
branch
from
October 18, 2026 18:38
f9df57b to
3ccbd11
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17465
Root cause
In
write_all_types(packages/kit/src/core/sync/write_types/index.js), the set of directories whose files should be kept is built withpath.posix.join(routes_dir, route.id). For the root route,route.idis'/', so the entry becomes e.g.src/routes/with a trailing slash. The cleanup loop compares that againstpath.posix.dirname(file), which never produces a trailing slash (src/routes). The root route's$types.d.tstherefore never matched and was deleted as surplus on every sync run (then wastefully rewritten, since the empty output dir forced regeneration).The fix strips the trailing slash when building the expected-directories set, so the comparison matches. No behavior change for any other route: only the root route id produces a trailing slash from
path.posix.join.Test evidence
New regression test
Root route $types.d.ts is not deleted on subsequent sync runsinpackages/kit/src/core/sync/write_types/index.spec.js: it builds a minimal project with a root route, runswrite_all_typestwice, and asserts the root$types.d.tsis never passed tormSyncon the second run.root $types.d.ts was deleted on a second sync run(the rmSpy recorded.../types/src/routes/$types.d.ts).pnpm vitest run src/core/sync/write_types/index.spec.js).Honest limits
pnpm run format,lint,check,prepublishOnly) was not run here; the changeset (patchfor@sveltejs/kit) follows the repo's convention. Happy to adjust if the checks surface anything.