Document LayoutParams, which differs from RouteParams
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
Consider src/routes/[foo]/[bar]/[baz]/+page.svelte route.
In the src/routes/[foo]/[bar]/+layout.ts's load function,
params.foo: stringparams.bar: stringparams.baz?: string | undefined
params.baz can be accessed, but it is not documented.
Current documentation.
// .svelte-kit/types/src/routes/[foo]/[bar]/[baz]/$types.d.ts
import type * as Kit from '@sveltejs/kit';
type RouteParams = {
foo: string;
bar: string;
baz: string;
}
export type PageServerLoad = Kit.ServerLoad<RouteParams>;
export type PageLoad = Kit.Load<RouteParams>;
Demo - Consider the following project structure.
.
└── src/
└── routes/
└── [foo]/
└── [bar]/
├── [baz]/
│ └── +page.server.js
└── +layout.server.js
The following types are generated by SvelteKit. (partially omitted)
// .svelte-kit/types/src/routes/[foo]/[bar]/[baz]/$types.d.ts
import type * as Kit from '@sveltejs/kit';
type RouteParams = { foo: string; bar: string; baz: string }
export type PageServerLoad = Kit.ServerLoad<RouteParams, PageServerParentData, OutputData, RouteId>;
// .svelte-kit/types/src/routes/[foo]/[bar]/$types.d.ts
import type * as Kit from '@sveltejs/kit';
type RouteParams = { foo: string; bar: string }
type LayoutParams = RouteParams & { foo?: string,bar?: string,baz?: string }
// type LayoutParams = { foo: string, bar: string, baz?: string | undefined }
export type LayoutServerLoad = Kit.ServerLoad<LayoutParams, LayoutServerParentData, OutputData, LayoutRouteId>;
Describe the proposed solution
Add documentations to
Alternatives considered
No response
Importance
nice to have
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Generated types and load documentation pages linked in the issue. Compare the documented RouteParams examples with the reported LayoutParams behavior, then explain the distinction using the provided nested-route example. Done means both documentation locations clearly describe which parameters are available to a layout load function.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100