Skip to content

feat: type resolve with the correct trailing slash option - #15027

Merged
teemingc merged 29 commits into
sveltejs:mainfrom
jycouet:feat/trail
Feb 14, 2026
Merged

feat: type resolve with the correct trailing slash option#15027
teemingc merged 29 commits into
sveltejs:mainfrom
jycouet:feat/trail

Conversation

@jycouet

@jycouet jycouet commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

If we have routes/path-a/+page.svelte

The function resolve() propose us two options today

resolve('/path-a')
resolve('/path-a/')

As trailing slash default is never, I would expect that resolve('/path-a/') is not available.
If you set always, I would expect only resolve('/path-a/') to be available.

This PR is addressing this.
But... not that happy that:

I added a few unit tests to help playing around.
Any help on the stuff I'm not happy about ?


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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • 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. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot

changeset-bot Bot commented Dec 4, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0c10c56

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

@svelte-docs-bot

Copy link
Copy Markdown

@teemingc teemingc changed the title resolve & trailing_slash feat: type resolve with the correct trailing slash option Dec 5, 2025
@teemingc

teemingc commented Feb 5, 2026

Copy link
Copy Markdown
Member

I've left two TODOs in packages/kit/src/core/sync/write_types/index.js and packages/kit/src/core/sync/sync.js. Aside from that, this PR is looking promising! Might even split out some of the static analysis changes so that it's easier to review.

@jycouet

jycouet commented Feb 6, 2026

Copy link
Copy Markdown
Contributor Author

I should get back at it! Thx 👍

@jycouet

jycouet commented Feb 7, 2026

Copy link
Copy Markdown
Contributor Author

I pulled main & looked at the TODOs, let me know what do you think @teemingc

Note: the Pathname update is now handled at the sync.js level after write_types() returns

@teemingc
teemingc marked this pull request as ready for review February 12, 2026 18:25

@teemingc teemingc 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.

Amazing! Thank you.

@teemingc
teemingc merged commit 0e3e4f6 into sveltejs:main Feb 14, 2026
25 checks passed
@github-actions github-actions Bot mentioned this pull request Feb 14, 2026
@jycouet
jycouet deleted the feat/trail branch February 23, 2026 08:31
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
…5027)

If we have `routes/path-a/+page.svelte`

The function `resolve()` propose us two options today
```ts
resolve('/path-a')
resolve('/path-a/')
```

As trailing slash default is `never`, I would expect that
`resolve('/path-a/')` is not available.
If you set `always`, I would expect only `resolve('/path-a/')` to be
available.

This PR is addressing this.
But... not that happy that:
- [x] I have to `read` in
`packages/kit/src/core/sync/create_manifest_data/index.js`
- [x] didn't manage to use
https://github.com/jycouet/kit/blob/7acee7aef9ac80614f9a78635cdf4a2a23785961/packages/kit/src/exports/vite/static_analysis/index.js#L213
as it's async

I added a few unit tests to help playing around.
Any help on the stuff I'm not happy about ?

---

### 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.
- [x] 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. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.

---------

Co-authored-by: Tee Ming <chewteeming01@gmail.com>
@teemingc teemingc linked an issue Jul 30, 2026 that may be closed by this pull request
elliott-with-the-longest-name-on-github added a commit that referenced this pull request Jul 30, 2026
…uteId` (#16580)

Closes #14847. #15027 fixed the `Path` half of that issue; the `RouteId`
union still lists every directory, so `resolve('/a')` type-checks when
`/a` only holds child routes.

`LayoutParams` now keys off the generated layout map instead of
`RouteId`, and a layout sitting in a directory that isn't a route stops
claiming its own id in `LayoutRouteId`.

`resolve('/')` stops type-checking in an app whose root page lives in a
group, since `/(app)` is the route that serves `/`. Write `resolve('')`
instead.

#16588 covers the `$app/manifest` side. Also points #16588's `routes`
filter at `is_app_route` so the two stay in sync, and rewords its
changeset to cover the #5793 fix.

---------

Co-authored-by: Elliott Johnson <hello@ell.iott.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated Pathname type resolves to non-route paths

2 participants