Skip to content

Commit 3d34bf6

Browse files
committed
Apply changes from review
1 parent ea0c55e commit 3d34bf6

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

.changeset/ten-onions-talk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'@sveltejs/kit': minor
33
---
44

5-
feat: provide PageProps, LayoutProps types
5+
feat: provide `PageProps` and `LayoutProps` types

documentation/docs/20-core-concepts/10-routing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Pages can receive data from `load` functions via the `data` prop.
4242
```svelte
4343
<!--- file: src/routes/blog/[slug]/+page.svelte --->
4444
<script>
45-
/** @type {{ data: import('./$types').PageProps }} */
45+
/** @type {import('./$types').PageProps} */
4646
let { data } = $props();
4747
</script>
4848
@@ -51,7 +51,7 @@ Pages can receive data from `load` functions via the `data` prop.
5151
```
5252

5353
> [!LEGACY]
54-
> `PageProps` was added in 2.16.0. In earlier versions, you can type the `data` property manually with `PageData` instead, see [$types](#\$types).
54+
> `PageProps` was added in 2.16.0. In earlier versions, you had to type the `data` property manually with `PageData` instead, see [$types](#\$types).
5555
>
5656
> In Svelte 4, you'd use `export let data` instead.
5757
@@ -230,7 +230,7 @@ We can create a layout that only applies to pages below `/settings` (while inher
230230
```
231231

232232
> [!LEGACY]
233-
> `LayoutProps` was added in 2.16.0. In earlier versions, you can [type the properties manually instead](#\$types).
233+
> `LayoutProps` was added in 2.16.0. In earlier versions, you had to [type the properties manually instead](#\$types).
234234
235235
You can see how `data` is populated by looking at the `+layout.js` example in the next section just below.
236236

@@ -393,7 +393,7 @@ export async function fallback({ request }) {
393393
394394
Throughout the examples above, we've been importing types from a `$types.d.ts` file. This is a file SvelteKit creates for you in a hidden directory if you're using TypeScript (or JavaScript with JSDoc type annotations) to give you type safety when working with your root files.
395395
396-
For example, annotating `let { data } = $props()` with `PageProps` tells TypeScript that the type of `data` is whatever was returned from `load`:
396+
For example, annotating `let { data } = $props()` with `PageProps` (or `LayoutProps`, for a `+layout.svelte` file) tells TypeScript that the type of `data` is whatever was returned from `load`:
397397
398398
```svelte
399399
<!--- file: src/routes/blog/[slug]/+page.svelte --->
@@ -404,7 +404,7 @@ For example, annotating `let { data } = $props()` with `PageProps` tells TypeScr
404404
```
405405
406406
> [!NOTE]
407-
> The `PageProps` and `LayoutProps` types, added in 2.16.0, are a shortcut for typing the `data` prop as `PageData` or `LayoutData`, as well as other props, such as `form` for pages, or `children` for layouts. In earlier versions, you can type these properties manually, for example for a page:
407+
> The `PageProps` and `LayoutProps` types, added in 2.16.0, are a shortcut for typing the `data` prop as `PageData` or `LayoutData`, as well as other props, such as `form` for pages, or `children` for layouts. In earlier versions, you had to type these properties manually. For example, for a page:
408408
>
409409
> ```js
410410
> /// file: +page.svelte

documentation/docs/20-core-concepts/20-load.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function load({ params }) {
3333
```
3434

3535
> [!LEGACY]
36-
> Before version 2.16.0, the props of a page/layout have to be typed individually:
36+
> Before version 2.16.0, the props of a page and layout had to be typed individually:
3737
> ```js
3838
> /// file: +page.svelte
3939
> /** @type {{ data: import('./$types').PageData }} */
@@ -119,7 +119,7 @@ export async function load() {
119119
```
120120

121121
> [!LEGACY]
122-
> `LayoutProps` was added in 2.16.0, in earlier versions props can be typed like so:
122+
> `LayoutProps` was added in 2.16.0. In earlier versions, properties had to be typed individually:
123123
> ```js
124124
> /// file: +layout.svelte
125125
> /** @type {{ data: import('./$types').LayoutData, children: Snippet }} */

documentation/docs/20-core-concepts/30-form-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export const actions = {
152152
```
153153
154154
> [!LEGACY]
155-
> `PageProps` was added in 2.16.0, in earlier versions you can type the `data` and `form` properties individually:
155+
> `PageProps` was added in 2.16.0. In earlier versions, you had to type the `data` and `form` properties individually:
156156
> ```js
157157
> /// file: +page.svelte
158158
> /** @type {{ data: import('./$types').PageData, form: import('./$types').ActionData }} */

0 commit comments

Comments
 (0)