summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matt Kane <m@mk.gg> 2024-12-03 16:16:42 +0000
committerGravatar GitHub <noreply@github.com> 2024-12-03 16:16:42 +0000
commit072492982b338e04549ee576ca7d8480be92cc1c (patch)
treea21ba41c21c6bd062ee3cdc88dd2590a948433ee
parentc17a364b1060a5afb383b75e3fc05892ab3e54f5 (diff)
downloadastro-072492982b338e04549ee576ca7d8480be92cc1c.tar.gz
astro-072492982b338e04549ee576ca7d8480be92cc1c.tar.zst
astro-072492982b338e04549ee576ca7d8480be92cc1c.zip
fix: include undefined in types for getEntry with content layer (#12601)
-rw-r--r--.changeset/fuzzy-bats-try.md5
-rw-r--r--packages/astro/templates/content/types.d.ts4
2 files changed, 8 insertions, 1 deletions
diff --git a/.changeset/fuzzy-bats-try.md b/.changeset/fuzzy-bats-try.md
new file mode 100644
index 000000000..c4aa53caf
--- /dev/null
+++ b/.changeset/fuzzy-bats-try.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Includes "undefined" in types for getEntry
diff --git a/packages/astro/templates/content/types.d.ts b/packages/astro/templates/content/types.d.ts
index 0727ac2e5..14b57053c 100644
--- a/packages/astro/templates/content/types.d.ts
+++ b/packages/astro/templates/content/types.d.ts
@@ -92,7 +92,9 @@ declare module 'astro:content' {
collection: C,
id: E,
): E extends keyof DataEntryMap[C]
- ? Promise<DataEntryMap[C][E]>
+ ? string extends keyof DataEntryMap[C]
+ ? Promise<DataEntryMap[C][E]> | undefined
+ : Promise<DataEntryMap[C][E]>
: Promise<CollectionEntry<C> | undefined>;
/** Resolve an array of entry references from the same collection */