I am currently using the following in my hooks.ts
file in a SvelteKit app:
export async function handle({ event, resolve }) { console.log(event.locals) //<-- Works fine}
I'm trying to figure out how to use types on the event
and resolve
parameters. As far as I can tell, event
works like this:
import type { RequestEvent } from '@sveltejs/kit'export async function handle(event: RequestEvent, resolve: ???){ ...}
But I can't figure out how to type the resolve
parameter. The docs here show this:
interface Handle { (input: { event: RequestEvent; resolve( event: RequestEvent, opts?: ResolveOptions ): MaybePromise<Response>; }): MaybePromise<Response>;}
From my limited TypeScript knowledge, it looks like resolve
is a function with two parameters that returns a promise. But how do I write that out in the handle
function declaration?