feat: allow resolve() to accept pathnames with query strings and hash fragments

#15458

Closing issues

Pull request

Merged at Mar 3, 2026, 11:03 AM by teemingc
B
BridgerB
Feb 28, 2026, 8:54 PM

Summary

Adds a ResolvablePath type that extends Pathname with optional ?${string} and #${string} suffixes, allowing resolve() to accept pathnames with query strings and hash fragments.

  • No runtime changes — resolve_route() already passes through ? and # correctly
  • Pathname type is unchanged (still used for page.url.pathname)
  • Existing resolve() behavior with route IDs and params is unaffected

Motivation

Currently there is no way to use goto() with query strings or hash fragments without either disabling the lint rule or bypassing resolve():

  1. resolve('/products?page=2') fails type-checking (Pathname doesn't include ?)
  2. goto(resolve('/products') + '?page=2') fails the svelte/no-navigation-without-resolve lint rule (argument isn't a resolve() call)

Per @teemingc's suggestion in :

"It should be possible to add a union type with a template string such as /my-route#${string} and /my-route?${string}. This would continue to keep the function type-safe."

This is a minimal type-only fix that doesn't conflict with (which adds richer { hash, searchParams } options).

What this enables

// All of these now type-check AND satisfy the lint rule:
goto(resolve('/products?page=2'));
goto(resolve(`/search?${params}`));
goto(resolve('/docs/intro#getting-started'));

Test plan

  • pnpm check passes
  • pnpm lint passes
  • Existing tests pass (no runtime changes, only type widening)

Closes