-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Type route id and params together #15619
Copy link
Copy link
Open
Labels
Description
Describe the problem
import { resolve } from "$app/paths";
import { page } from "$app/state";
// TypeScript does not know that the params will always match the route id here:
resolve(page.route.id, page.params)Describe the proposed solution
Would it be possible to let TypeScript know that the params match the route id if we put params inside route? So instead of having page.route.id be any RouteId and page.params be any Params, page.route would be something like
type Route =
| { id: "/"; params: never }
| { id: "/admin/[id]"; params: { id: string } }
| { id: "/[locale=locale]/test"; params: { locale: "en" | "nb" } };Then I think TypeScript would be able to know that params match id, and would not complain on resolve(page.route.id, page.route.params).
Alternatives considered
No response
Importance
nice to have
Additional Information
No response
Reactions are currently unavailable