Skip to content

page.url.pathname types are wrong inside layout groups #14043

@peppasd

Description

@peppasd

Describe the bug

The resolved types of page.url.pathname from the $app/state rune inside a layout group include the group name, however the group name is not part of the URL.

This bug was probably introduced with SvelteKit 2.26 and this PR

Example file structure:

src/routes/
│ (group)/
│ ├ path-a/
│ └ +layout.svelte

Expected type: "/path-a"
Resolved type: "/(group)/path-a"

Reproduction

Here's a repo reproducing this issue: https://github.com/peppasd/svelte-typed-pathname-groups-repro

By opening the file src/routes/(main)/+layout.svelte typescript will show the following error:

Image

Logs

System Info

System:
    OS: macOS 15.5
    CPU: (11) arm64 Apple M3 Pro
    Memory: 107.28 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.1.0 - ~/.nvm/versions/node/v24.1.0/bin/node
    npm: 11.3.0 - ~/.nvm/versions/node/v24.1.0/bin/npm
    bun: 1.2.19 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 138.0.7204.158
    Safari: 18.5
  npmPackages:
    @sveltejs/adapter-auto: ^6.0.0 => 6.0.1 
    @sveltejs/kit: ^2.22.0 => 2.26.0 
    @sveltejs/vite-plugin-svelte: ^6.0.0 => 6.1.0 
    svelte: ^5.0.0 => 5.36.16 
    vite: ^7.0.4 => 7.0.6

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions