diff options
-rw-r--r-- | .changeset/fair-bottles-lie.md | 5 | ||||
-rw-r--r-- | packages/astro/src/@types/astro.ts | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/.changeset/fair-bottles-lie.md b/.changeset/fair-bottles-lie.md new file mode 100644 index 000000000..8dc9c988a --- /dev/null +++ b/.changeset/fair-bottles-lie.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Adds a second generic parameter to `APIRoute` to type the `params` diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 04ca6b1f9..104c60598 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -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 { |