Skip to content

Passing Pathname to resolve not allowed #15108

@backstromjoel

Description

@backstromjoel

Describe the bug

When calling resolve(route) with a route thats a Pathname, you get a TS2345.

The behavior I was expecting was for resolve to accept a Pathname or a RouteId, not just the string literal.

If this behnavior is indented, could we clarify why and how to handle dynamically created routes (variables) using resolve? https://svelte.dev/docs/kit/$app-paths#resolve

Image

Reproduction

<script lang="ts">
	import type { Pathname } from '$app/types';
	import { resolve } from '$app/paths';

	const route = '/' as Pathname;
</script>

<a href={resolve(route)}> Example </a>

Logs

System Info

System:
    OS: macOS 26.1
    CPU: (8) arm64 Apple M3
    Memory: 73.50 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - /Users/backstromjoel/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - /Users/backstromjoel/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 10.7.0 - /Users/backstromjoel/Library/pnpm/pnpm
    bun: 1.1.27 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 143.0.7499.170
    Safari: 26.1
  npmPackages:
    svelte: ^5.46.1 => 5.46.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions