From 69af893f7eaf0a9523316c69eab7e327167dc924 Mon Sep 17 00:00:00 2001 From: Andreas Fehn Date: Fri, 25 Apr 2025 10:50:13 +0200 Subject: [PATCH] Make types for load wrapper easier to use --- src/lib/server.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/server.ts b/src/lib/server.ts index 5c0bbca..717627d 100644 --- a/src/lib/server.ts +++ b/src/lib/server.ts @@ -19,19 +19,19 @@ export const flashCookieOptions: CookieSerializeOptions = { /** * @deprecated Renamed to loadFlash. */ -export function loadFlashMessage(cb: S) { - return loadFlash(cb); +export function loadFlashMessage(load: (event: E) => R) { + return loadFlash(load); } /** * Retrieves the flash message from the previous request. * Use as a wrapper around a top-level load function, usually in a +layout.server.ts file. */ -export function loadFlash(cb: S) { +export function loadFlash(load: (event: E) => R) { return async (event: E) => { const flash = _loadFlash(event).flash; - const loadFunction = await cb(event); - return { flash, ...loadFunction } as ReturnType; + const loadReturn = await load(event); + return { flash, ...loadReturn } as typeof loadReturn; }; }