-
- Notifications
You must be signed in to change notification settings - Fork 2.2k
[breaking] replace routeId with route.id #7450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 85d15e1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| Is there anything else we foresee living in Whatever we do, for consistency I'd be in favor of having |
|
|
| The site is failing to deploy because a code snippet in the docs references |
| I made that change for export interface RequestHandler< Params extends Partial<Record<string, string>> = Partial<Record<string, string>> > { -(event: RequestEvent<Params>): MaybePromise<Response>; +(event: RequestEvent<Params> & { route: { id: string } }): MaybePromise<Response>; }...then it works, but this is what I get if I hover over Not totally ideal. Do we need to come up with a new type that extends |
| I thought this, too, but in some cases the root layout is loaded but without a route - for example when an infinite redirect loop is detected, or in case of a 404 - many ugh-vibes on this PR 😅 |
| Ah crap, you're right — will revert the last commit. What if we went the generic route though, and made // .svelte-kit/types/src/routes/blog/$types.d.ts export type PageLoad<...> = Kit.Load<..., OutputData, 'blog'>; export type LayoutLoad<...> = Kit.Load<..., OutputData, 'blog' | 'blog/[slug]'>;Or is it misleading for the route object to exist when no route matched? |
| Funny how we go through the same thought process independently. I asked myself the same question, and came to the conclusion that it's weird. Then again, all of this is weird, so we need to choose something that is the least weird while being easy enough to use. After having implemented this, part of me thinks |
| And just as I'd come around to I think parity with
Yeah, I think the main use case is where you want some special case logic in a layout ('require the user to be logged in, unless the current |
| I like |
| Params extends Partial<Record<string, string>> = Partial<Record<string, string>>, | ||
| OutputData extends Record<string, any> | void = Record<string, any> | void | ||
| OutputData extends Record<string, any> | void = Record<string, any> | void, | ||
| RouteId extends string | null = string | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the overhead of that interface on the action interfaces? Actions can only be used on pages, so routeId can only be one thing, so it's useless to use it, so probably noone does that, so we probably can just type this as string on RequestEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any real drawback? It's contrived but you could imagine someone doing this sort of thing, where some_shared_logic is picky about the second argument:
export const actions = { blah: ({ request, route }) => { some_shared_logic(request, route.id); } };| Does that mean this also closes #6167? |
| no, because that relates to |
| Doesn't the same apply to params and url as well? Not sure if we need to optimize for this. |
| Ok that was a bit of a faff but it will now correctly identify the dependency on /** @type {import('./$types').LayoutServerLoad} */ export function load({ route }) { return { route }; }.,..and the same goes for |


Closes #6980
Draft, because the tracking part is missing, and I'm not sure yet if we want to replace routeId in all places (like
$page.routeId)Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. All changesets should bepatchuntil SvelteKit 1.0