From 65882860cb9c15bdd068f37b4b4342f1f42216dc Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 26 Jan 2023 12:25:01 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20Don=E2=80=99t=20require=20`getCollection?= =?UTF-8?q?()`=20filter=20to=20be=20a=20type=20guard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit dabce6b8c684f851c3535f8acead06cbef6dce2a (#5970) broke the use of a plain boolean filter. Add an overload similar to TypeScript’s Array#filter overload: https://github.com/microsoft/TypeScript/blob/v4.9.4/lib/lib.es5.d.ts#L1442-L1453 Signed-off-by: Anders Kaseorg --- packages/astro/src/content/template/types.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/astro/src/content/template/types.d.ts b/packages/astro/src/content/template/types.d.ts index 628f5d18df120..7dbe478ce3242 100644 --- a/packages/astro/src/content/template/types.d.ts +++ b/packages/astro/src/content/template/types.d.ts @@ -48,6 +48,10 @@ declare module 'astro:content' { collection: C, filter?: (entry: CollectionEntry) => entry is E ): Promise; + export function getCollection( + collection: C, + filter?: (data: CollectionEntry) => unknown + ): Promise[]>; type InferEntrySchema = import('astro/zod').infer< Required['schema']