diff --git a/.changeset/cold-wasps-flow.md b/.changeset/cold-wasps-flow.md new file mode 100644 index 000000000000..fd896ed95187 --- /dev/null +++ b/.changeset/cold-wasps-flow.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Allow ActionData to be undefined diff --git a/packages/kit/src/core/sync/write_types/index.js b/packages/kit/src/core/sync/write_types/index.js index a7c82f905059..fc18f0c0eca2 100644 --- a/packages/kit/src/core/sync/write_types/index.js +++ b/packages/kit/src/core/sync/write_types/index.js @@ -308,7 +308,7 @@ function process_node(node, outdir, is_page, all_pages_have_load = true) { ? `./proxy${replace_ext_with_js(basename)}` : path_to_original(outdir, node.server); - type = `Expand>`; + type = `Expand> | undefined`; } } exports.push(`export type ActionData = ${type};`); diff --git a/packages/kit/src/core/sync/write_types/test/simple-page-server-only/_expected/$types.d.ts b/packages/kit/src/core/sync/write_types/test/simple-page-server-only/_expected/$types.d.ts index 4b2b444d2b30..597cd9a16ce6 100644 --- a/packages/kit/src/core/sync/write_types/test/simple-page-server-only/_expected/$types.d.ts +++ b/packages/kit/src/core/sync/write_types/test/simple-page-server-only/_expected/$types.d.ts @@ -21,9 +21,9 @@ export type PageServerLoad< OutputData extends OutputDataShape = OutputDataShape > = Kit.ServerLoad; export type PageServerLoadEvent = Parameters[0]; -export type ActionData = Expand< - Kit.AwaitedActions ->; +export type ActionData = + | Expand> + | undefined; export type PageServerData = Expand< Kit.AwaitedProperties< Awaited>