Skip to content

resolve return value doesn’t match type / ResolvedPathname type is misleading #14295

@felix-schindler

Description

@felix-schindler

Describe the bug

Since base was deprecated, I’ve updated my project to use the resolve function. However, I noticed that during render, resolve sometimes returns a relative path (e.g. "./about") instead of an absolute path (e.g. "/about").

The issue is that the return type, ResolvedPathname, specifies that all paths should be absolute. This makes the type misleading, since the actual return value can be relative.

I would expect one of two fixes:

  1. resolve should always return absolute paths, or
  2. If returning relative paths is intended, then the ResolvedPathname type should be updated so users know the real shape of the returned string.

Right now, the type and the runtime behavior don’t match.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-resolve-type

Logs

Server console output:


false [ './', './about' ]


Client console output:


false ['/', './about']
true  ['/', '/about']
true  ['/', '/about']

System Info

System:
    OS: macOS 15.6.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 218.63 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.6.0 - /opt/homebrew/bin/node
    Yarn: 4.9.3 - /opt/homebrew/bin/yarn
    npm: 11.5.1 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 139.0.7258.128
    Safari: 18.6
  npmPackages:
    @sveltejs/adapter-node: ^5.3.1 => 5.3.1
    @sveltejs/kit: ^2.36.1 => 2.36.1
    @sveltejs/vite-plugin-svelte: ^6.1.3 => 6.1.3
    svelte: ^5.38.2 => 5.38.2
    vite: ^7.1.3 => 7.1.3

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions