sveltejs / sveltejs/kit

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

Open
#14,295 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

paths.base types / typescript
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and the resolve entry point; compare its relative-path returns with the ResolvedPathname type. Determine whether the intended result is absolute paths or an updated type, then verify that the chosen behavior matches the server and client outputs shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.