Skip to content

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

Open
Nic-Polumeyv wants to merge 7 commits into
sveltejs:version-3from
Nic-Polumeyv:fix-app-types-path-template
Open

fix: generate valid Path types for routes with optional or rest params, several params in one segment, or escape sequences#16577
Nic-Polumeyv wants to merge 7 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
Contributor

/[[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.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 30, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 15d2da7:

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

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.

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 15d2da7

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

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as draft July 30, 2026 02:37

@Rich-Harris Rich-Harris 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!

@Nic-Polumeyv

Nic-Polumeyv commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

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

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review July 30, 2026 18:49
@Nic-Polumeyv Nic-Polumeyv 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

@vercel vercel Bot 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

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