Skip to content

fix: generate valid Path types for routes with optional or rest params, several params in one segment, or escape sequences - #16577

Merged
Rich-Harris merged 9 commits into
sveltejs:version-3from
Nic-Polumeyv:fix-app-types-path-template
Aug 4, 2026
Merged

Rich-Harris merged 9 commits into
sveltejs:version-3from
Nic-Polumeyv:fix-app-types-path-template

Conversation

@Nic-Polumeyv

@Nic-Polumeyv Nic-Polumeyv commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

/[[lang]]/about generates the Path member {string}/about, a plain string rather than a template: #16430 appended .slice(1) to a branch whose replacement had already consumed the leading slash, chopping the $. Since resolve() is bounded by Path, resolve('en/about') is rejected while resolve('{string}/about') type checks.

The pathname is now built from the route's segments. An omitted optional param contributes its own pathname instead of absorbing the following /, so xyzabout is no longer admitted, and a second param in one segment (/[foo]-[bar]) no longer leaks in verbatim.

Rest params get the same treatment, since [...path] can match zero segments. Escape sequences are expanded the same way #16570 expands them in resolve, so /[x+2e]well-known contributes .well-known rather than the raw route id.

ghost commented Jul 30, 2026 •

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from ac1da74:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/ac1da74e80134df85cf4db75aca16dede29100dc

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16577

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

ghost commented Jul 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ac1da74

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

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

@ghost
ghost marked this pull request as draft July 30, 2026 02:37

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

ghost commented Jul 30, 2026 •

Copy link
Copy Markdown
Member Author

Needed to tidy up a few things and fix an omission bug. Opening in a couple min!

@ghost
ghost marked this pull request as ready for review July 30, 2026 18:49
@ghost ghost changed the title fix: generate valid Path types for routes with an optional first segment or several params in one segment fix: generate valid Path types for routes with optional or rest params, several params in one segment, or escape sequences Jul 30, 2026

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Call to undefined remove_group_segments in write_app_types.js throws ReferenceError on the first route, breaking svelte-kit sync type generation.

Fix on Vercel

@ghost
ghost merged commit c3f58bb into sveltejs:version-3 Aug 4, 2026
@ghost ghost mentioned this pull request Aug 4, 2026
@ghost
ghost deleted the fix-app-types-path-template branch August 4, 2026 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants