Skip to content

Use matcher type in AppTypes (e.g. resolve()) #15062

@hyunbinseo

Description

@hyunbinseo

Describe the bug

Current implementation of resolve can result in nonexistent routes:

// src/params/type.ts
export const match = (type: string) => type === 'a' || type === 'b';
// src/routes/[type=type]/+page.svelte

import { resolve } from '$app/paths';

resolve('/[type=type]', {
  type: 'c' // any string is accepted
});

export const load = ({ params }) => {
  // This comparison appears to be unintentional because
  // the types "a" | "b" and "c" have no overlap. (ts 2367)
  if (params.type === 'c') return;
};

Reproduction

https://github.com/hyunbinseo/svelte-kit-15062

System Info

System:
  OS: Windows 11 10.0.26200
  CPU: (8) x64 Intel(R) Core(TM) Ultra 7 258V
  Memory: 4.55 GB / 31.48 GB
Binaries:
  Node: 24.12.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\22256_1765770337865\node.EXE
  Yarn: 1.22.22 - C:\Users\hyunb\AppData\Local\fnm_multishells\22256_1765770337865\yarn.CMD
  npm: 11.6.2 - C:\Users\hyunb\AppData\Local\fnm_multishells\22256_1765770337865\npm.CMD
  pnpm: 10.25.0 - C:\Users\hyunb\AppData\Local\fnm_multishells\22256_1765770337865\pnpm.CMD
  Deno: 2.4.0 - C:\Users\hyunb\.deno\bin\deno.EXE
Browsers:
  Chrome: 143.0.7499.109
  Edge: Chromium (140.0.3485.54)
  Firefox: 146.0 - C:\Program Files\Mozilla Firefox\firefox.exe
npmPackages:
  @sveltejs/adapter-auto: ^7.0.0 => 7.0.0
  @sveltejs/kit: ^2.49.2 => 2.49.2
  @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.1
  svelte: ^5.46.0 => 5.46.0
  vite: ^7.2.7 => 7.2.7

Severity

annoyance

Additional Information

Related (or possible duplicate of) #14051

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions