sveltejs / sveltejs/kit

`RouteId` is not a valid param for `resolve()`

Open
#15,536 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

Hi, starting somewhere on 2.50+ (cannot remember exact version, sorry), I started getting strange errors, where a manually type RouteId cannot be passed as a first argument to resolve(), even though it should explicitly work with that as per the docs.

Reproduction

The linked Stackblitz doesn't boot, so a more full repro:

<script lang="ts">
  import type { RouteId } from "$app/types";

  import { goto } from "$app/navigation";
  import { resolve } from "$app/paths";

  void goto(
    resolve("whatever" as RouteId),
  );
</script>
Logs
I get this when running svelte-check:

Error: Argument of type '["/" | "/blog" | "/blog/hyperparameter-optimization-for-gnns-with-transfer-learning" | "/publications" | "/teaching" | "/teaching/LAL1" | "/teaching/LAL1/2021-winter" | ... 19 more ... | "/vyuka"]' is not assignable to parameter of type '[route: "/"] | [route: "/blog"] | [route: "/blog/hyperparameter-optimization-for-gnns-with-transfer-learning"] | [route: "/publications"] | [route: "/teaching"] | [route: "/teaching/LAL1"] | [route: "/teaching/LAL1/2021-winter"] | ... 19 more ... | [route: ...]'.
  Type '["/" | "/blog" | "/blog/hyperparameter-optimization-for-gnns-with-transfer-learning" | "/publications" | "/teaching" | "/teaching/LAL1" | "/teaching/LAL1/2021-winter" | ... 19 more ... | "/vyuka"]' is not assignable to type '[route: "/vyuka"]'.
    Type '"/" | "/blog" | "/blog/hyperparameter-optimization-for-gnns-with-transfer-learning" | "/publications" | "/teaching" | "/teaching/LAL1" | "/teaching/LAL1/2021-winter" | ... 19 more ... | "/vyuka"' is not assignable to type '"/vyuka"'.
      Type '"/"' is not assignable to type '"/vyuka"'. (ts)
      void goto(
        resolve(`/teaching/${course?.slug ?? ""}/${newVersion}` as RouteId),
      );
System Info
❯ npx envinfo --system --binaries --browsers --npmPackages "{svelte,@sveltejs/*,vite}"

  System:
    OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
    CPU: (24) x64 AMD Ryzen AI 9 HX 370 w/ Radeon 890M
    Memory: 14.28 GB / 30.13 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 24.11.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.8.0 - /usr/bin/npm
    pnpm: 10.30.0 - /usr/bin/pnpm
  Browsers:
    Firefox: 148.0
    Firefox Developer Edition: 148.0
  npmPackages:
    @sveltejs/adapter-static: ^3.0.10 => 3.0.10
    @sveltejs/enhanced-img: ^0.10.3 => 0.10.3
    @sveltejs/kit: ^2.54.0 => 2.54.0
    @sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4
    svelte: ^5.53.6 => 5.53.6
    vite: ^7.3.1 => 7.3.1
Severity

serious, but I can work around it

Additional Information

I was waiting for 2.54 and tried RouteIdWithSearchOrParams, but that doesn't fix it either.

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 at the $app/paths resolve() entry point and the RouteId type in $app/types, then reproduce the issue with the provided TypeScript snippet under svelte-check. Done means a manually cast RouteId is accepted by resolve(), including RouteIdWithSearchOrParams, without the reported type error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.