Skip to content

Commit

Permalink
[fix] ActionData type (#6748)
Browse files Browse the repository at this point in the history
Closes #6631
  • Loading branch information
dummdidumm authored Sep 13, 2022
1 parent 616ec7a commit 87b1243
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/blue-glasses-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] ActionData type
8 changes: 7 additions & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -39,6 +39,12 @@ export type AwaitedActions<T extends Record<string, (...args: any) => any>> = {
[Key in keyof T]: UnpackValidationError<Awaited<ReturnType<T[Key]>>>;
}[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<T extends Record<string, unknown> | undefined = undefined> {
status: number;
data: T;
}

type UnpackValidationError<T> = T extends ValidationError<infer X> ? X : T;

export interface Builder {
Expand Down

0 comments on commit 87b1243

Please sign in to comment.