@@ -38,6 +38,14 @@ declare module '@sveltejs/kit' {
3838 A extends keyof U = U extends U ? keyof U : never
3939 > = U extends unknown ? { [ P in Exclude < A , keyof U > ] ?: never } & U : never ;
4040
41+ const uniqueSymbol : unique symbol ;
42+
43+ export interface ActionFailure < T extends Record < string , unknown > | undefined = undefined > {
44+ status : number ;
45+ data : T ;
46+ [ uniqueSymbol ] : true ; // necessary or else UnpackValidationError could wrongly unpack objects with the same shape as ActionFailure
47+ }
48+
4149 type UnpackValidationError < T > = T extends ActionFailure < infer X >
4250 ? X
4351 : T extends void
@@ -1494,28 +1502,6 @@ declare module '@sveltejs/kit' {
14941502 }
14951503
14961504 type TrailingSlash = 'never' | 'always' | 'ignore' ;
1497- class HttpError_1 {
1498-
1499- constructor ( status : number , body : {
1500- message : string ;
1501- } extends App . Error ? ( App . Error | string | undefined ) : App . Error ) ;
1502- status : number ;
1503- body : App . Error ;
1504- toString ( ) : string ;
1505- }
1506- class Redirect_1 {
1507-
1508- constructor ( status : 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 , location : string ) ;
1509- status : 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 ;
1510- location : string ;
1511- }
1512-
1513- export class ActionFailure < T extends Record < string , unknown > | undefined = undefined > {
1514-
1515- constructor ( status : number , data ?: T | undefined ) ;
1516- status : number ;
1517- data : T | undefined ;
1518- }
15191505 interface Asset {
15201506 file : string ;
15211507 size : number ;
@@ -1739,12 +1725,17 @@ declare module '@sveltejs/kit' {
17391725 * @param init Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.
17401726 */
17411727 export function text ( body : string , init ?: ResponseInit | undefined ) : Response ;
1728+ /**
1729+ * Create an `ActionFailure` object.
1730+ * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
1731+ * */
1732+ export function fail ( status : number ) : ActionFailure < undefined > ;
17421733 /**
17431734 * Create an `ActionFailure` object.
17441735 * @param status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
17451736 * @param data Data associated with the failure (e.g. validation errors)
17461737 * */
1747- export function fail < T extends Record < string , unknown > | undefined = undefined > ( status : number , data ? : T | undefined ) : ActionFailure < T > ;
1738+ export function fail < T extends Record < string , unknown > | undefined = undefined > ( status : number , data : T ) : ActionFailure < T > ;
17481739 /**
17491740 * Populate a route ID with params to resolve a pathname.
17501741 * @example
@@ -1762,6 +1753,21 @@ declare module '@sveltejs/kit' {
17621753 export type LessThan < TNumber extends number , TArray extends any [ ] = [ ] > = TNumber extends TArray [ 'length' ] ? TArray [ number ] : LessThan < TNumber , [ ...TArray , TArray [ 'length' ] ] > ;
17631754 export type NumericRange < TStart extends number , TEnd extends number > = Exclude < TEnd | LessThan < TEnd > , LessThan < TStart > > ;
17641755 export const VERSION : string ;
1756+ class HttpError_1 {
1757+
1758+ constructor ( status : number , body : {
1759+ message : string ;
1760+ } extends App . Error ? ( App . Error | string | undefined ) : App . Error ) ;
1761+ status : number ;
1762+ body : App . Error ;
1763+ toString ( ) : string ;
1764+ }
1765+ class Redirect_1 {
1766+
1767+ constructor ( status : 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 , location : string ) ;
1768+ status : 301 | 302 | 303 | 307 | 308 | 300 | 304 | 305 | 306 ;
1769+ location : string ;
1770+ }
17651771}
17661772
17671773declare module '@sveltejs/kit/hooks' {
0 commit comments