diff options
-rw-r--r-- | .changeset/grumpy-readers-draw.md | 5 | ||||
-rw-r--r-- | packages/astro/src/@types/astro.ts | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/.changeset/grumpy-readers-draw.md b/.changeset/grumpy-readers-draw.md new file mode 100644 index 000000000..32156bc8b --- /dev/null +++ b/.changeset/grumpy-readers-draw.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Add `Props` generic for `APIRoute` type diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index ef958d2a8..69c0ffed5 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1764,21 +1764,21 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a locals: App.Locals; } -export type Props = Record<string, unknown>; - export interface EndpointOutput { body: Body; encoding?: BufferEncoding; } -export type APIRoute = ( - context: APIContext +export type APIRoute<Props extends Record<string, any> = Record<string, any>> = ( + context: APIContext<Props> ) => EndpointOutput | Response | Promise<EndpointOutput | Response>; export interface EndpointHandler { [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response); } +export type Props = Record<string, unknown>; + export interface AstroRenderer { /** Name of the renderer. */ name: string; |