diff --git a/.changeset/spotty-jars-kiss.md b/.changeset/spotty-jars-kiss.md new file mode 100644 index 000000000000..da2aaa6bd6b6 --- /dev/null +++ b/.changeset/spotty-jars-kiss.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': major +--- + +Add 'PageProps' to './$types' diff --git a/documentation/docs/02-runes/05-$props.md b/documentation/docs/02-runes/05-$props.md new file mode 100644 index 000000000000..ef7039f4ae80 --- /dev/null +++ b/documentation/docs/02-runes/05-$props.md @@ -0,0 +1,28 @@ + +### PageProps + +For defining types of `$props` rune in `page.svelte`, you would normally do the following + +```svelte + + +``` + +If you don't want to write this for every page, you can do the following instead + +```svelte + + +``` \ No newline at end of file diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index 42728feaf187..66a7d325a692 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -465,6 +465,12 @@ function process_node(node, outdir, is_page, proxies, all_pages_have_load = true exports.push(`export type ${prefix}Data = ${data};`); + exports.push( + `export type ${prefix}Props = { data: ${prefix}Data; ${ + node.server && is_page ? 'form: ActionData; ' : '' + }};` + ); + return { declarations, exports, proxies }; /**