From 5d460bd2317a3cc7de7fff2eb2ab4cbf30ce537b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EB=8F=99=ED=98=84?= <79711744+ldh3907@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:49:38 +0900 Subject: [PATCH 1/2] feat(typescript): APIRoute added second generic --- packages/astro/src/@types/astro.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 04ca6b1f92ae..104c605985dc 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 = Record> = ( - context: APIContext +export type APIRoute = Record, APIParams extends Record = Record> = ( + context: APIContext ) => Response | Promise; export interface EndpointHandler { From 0b3c3877973df0133087b8364ab738331ca95b65 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 5 Jan 2024 16:33:42 +0800 Subject: [PATCH 2/2] Create fair-bottles-lie.md --- .changeset/fair-bottles-lie.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fair-bottles-lie.md diff --git a/.changeset/fair-bottles-lie.md b/.changeset/fair-bottles-lie.md new file mode 100644 index 000000000000..8dc9c988a16b --- /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`