From 4c9d1cb8f27d558807dbe3646c5b5fa1966b166f Mon Sep 17 00:00:00 2001 From: Oliver Speir <115520730+OliverSpeir@users.noreply.github.com> Date: Thu, 10 Aug 2023 06:39:36 -0600 Subject: [PATCH] Update content-types.template.d.ts (#8010) Provides more useful information when hovering variables typed with CollectionEntry<"collectionName"> * Does not change the functionality of existing code * Flatten is the same as AnyEntryMap[C][keyof AnyEntryMap[C]] * Both will produce a union of all note entry types within the "collectionName" key --- packages/astro/content-types.template.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/astro/content-types.template.d.ts b/packages/astro/content-types.template.d.ts index 277d00acf..c164fc297 100644 --- a/packages/astro/content-types.template.d.ts +++ b/packages/astro/content-types.template.d.ts @@ -10,7 +10,9 @@ declare module 'astro:content' { declare module 'astro:content' { export { z } from 'astro/zod'; - export type CollectionEntry = AnyEntryMap[C][keyof AnyEntryMap[C]]; + + type Flatten = T extends { [K: string]: infer U } ? U : never; + export type CollectionEntry = Flatten; // TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04 /**