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<AnyEntryMap[C]> is the same as AnyEntryMap[C][keyof AnyEntryMap[C]] * Both will produce a union of all note entry types within the "collectionName" key
This commit is contained in:
parent
1e3c9f515b
commit
4c9d1cb8f2
1 changed files with 3 additions and 1 deletions
4
packages/astro/content-types.template.d.ts
vendored
4
packages/astro/content-types.template.d.ts
vendored
|
@ -10,7 +10,9 @@ declare module 'astro:content' {
|
|||
|
||||
declare module 'astro:content' {
|
||||
export { z } from 'astro/zod';
|
||||
export type CollectionEntry<C extends keyof AnyEntryMap> = AnyEntryMap[C][keyof AnyEntryMap[C]];
|
||||
|
||||
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
||||
export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
|
||||
|
||||
// TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue