Skip to content

Commit

Permalink
feat: Add APIRoute second generic (#9618)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaaaaann authored Jan 5, 2024
1 parent 47b951b commit 401fd3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-bottles-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Adds a second generic parameter to `APIRoute` to type the `params`
4 changes: 2 additions & 2 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2262,8 +2262,8 @@ type Routing = {
strategy: 'pathname';
};

export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (
context: APIContext<Props>
export type APIRoute<Props extends Record<string, any> = Record<string, any>, APIParams extends Record<string, string | undefined> = Record<string, string | undefined>> = (
context: APIContext<Props, APIParams>
) => Response | Promise<Response>;

export interface EndpointHandler {
Expand Down

0 comments on commit 401fd3e

Please sign in to comment.