From 87b1243fdb3d4c98b0c17578649ee4efa492cf50 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:00:52 +0200 Subject: [PATCH] [fix] ActionData type (#6748) Closes #6631 --- .changeset/blue-glasses-compete.md | 5 +++++ packages/kit/types/index.d.ts | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/blue-glasses-compete.md diff --git a/.changeset/blue-glasses-compete.md b/.changeset/blue-glasses-compete.md new file mode 100644 index 000000000000..48fdd5011d78 --- /dev/null +++ b/.changeset/blue-glasses-compete.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +[fix] ActionData type diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 93e07eb47176..fedab7854435 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -16,7 +16,7 @@ import { TrailingSlash } from './private.js'; import { SSRNodeLoader, SSRRoute, ValidatedConfig } from './internal.js'; -import { HttpError, Redirect, ValidationError } from '../src/runtime/control.js'; +import { HttpError, Redirect } from '../src/runtime/control.js'; export { PrerenderOption } from './private.js'; @@ -39,6 +39,12 @@ export type AwaitedActions any>> = { [Key in keyof T]: UnpackValidationError>>; }[keyof T]; +// Needs to be here, else ActionData will be resolved to unknown - probably because of "d.ts file imports .js file" in combination with allowJs +interface ValidationError | undefined = undefined> { + status: number; + data: T; +} + type UnpackValidationError = T extends ValidationError ? X : T; export interface Builder {