diff options
author | 2024-01-05 22:58:49 +0900 | |
---|---|---|
committer | 2024-01-05 21:58:49 +0800 | |
commit | 401fd3e8c8957a3bed6469a622cd67b157ca303f (patch) | |
tree | 5a62fac6e259edcb589823dd0f5f13e06c796f04 | |
parent | 47b951b3888a5a8a708d2f9b974f12fba7ec9ed3 (diff) | |
download | astro-401fd3e8c8957a3bed6469a622cd67b157ca303f.tar.gz astro-401fd3e8c8957a3bed6469a622cd67b157ca303f.tar.zst astro-401fd3e8c8957a3bed6469a622cd67b157ca303f.zip |
feat: Add APIRoute second generic (#9618)
-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 { |