Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Nov 22, 2024
1 parent 5ea73d7 commit 8cfc1c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .astro/astro/content.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ declare module 'astro:content' {
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;

export type CollectionKey = keyof AnyEntryMap;

export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;

export type ContentCollectionKey = keyof ContentEntryMap;

export type DataCollectionKey = keyof DataEntryMap;

type AllValuesOf<T> = T extends any ? T[keyof T] : never;
Expand Down Expand Up @@ -53,6 +55,7 @@ declare module 'astro:content' {
collection: C,
filter?: (entry: CollectionEntry<C>) => entry is E,
): Promise<E[]>;

export function getCollection<C extends keyof AnyEntryMap>(
collection: C,
filter?: (entry: CollectionEntry<C>) => unknown,
Expand All @@ -67,6 +70,7 @@ declare module 'astro:content' {
}): E extends ValidContentEntrySlug<C>
? Promise<CollectionEntry<C>>
: Promise<CollectionEntry<C> | undefined>;

export function getEntry<
C extends keyof DataEntryMap,
E extends keyof DataEntryMap[C] | (string & {}),
Expand All @@ -76,6 +80,7 @@ declare module 'astro:content' {
}): E extends keyof DataEntryMap[C]
? Promise<DataEntryMap[C][E]>
: Promise<CollectionEntry<C> | undefined>;

export function getEntry<
C extends keyof ContentEntryMap,
E extends ValidContentEntrySlug<C> | (string & {}),
Expand All @@ -85,6 +90,7 @@ declare module 'astro:content' {
): E extends ValidContentEntrySlug<C>
? Promise<CollectionEntry<C>>
: Promise<CollectionEntry<C> | undefined>;

export function getEntry<
C extends keyof DataEntryMap,
E extends keyof DataEntryMap[C] | (string & {}),
Expand All @@ -102,6 +108,7 @@ declare module 'astro:content' {
slug: ValidContentEntrySlug<C>;
}[],
): Promise<CollectionEntry<C>[]>;

export function getEntries<C extends keyof DataEntryMap>(
entries: {
collection: C;
Expand Down
7 changes: 7 additions & 0 deletions .astro/content.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ declare module 'astro:content' {
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;

export type CollectionKey = keyof AnyEntryMap;

export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;

export type ContentCollectionKey = keyof ContentEntryMap;

export type DataCollectionKey = keyof DataEntryMap;

type AllValuesOf<T> = T extends any ? T[keyof T] : never;
Expand Down Expand Up @@ -53,6 +55,7 @@ declare module 'astro:content' {
collection: C,
filter?: (entry: CollectionEntry<C>) => entry is E,
): Promise<E[]>;

export function getCollection<C extends keyof AnyEntryMap>(
collection: C,
filter?: (entry: CollectionEntry<C>) => unknown,
Expand All @@ -67,6 +70,7 @@ declare module 'astro:content' {
}): E extends ValidContentEntrySlug<C>
? Promise<CollectionEntry<C>>
: Promise<CollectionEntry<C> | undefined>;

export function getEntry<
C extends keyof DataEntryMap,
E extends keyof DataEntryMap[C] | (string & {}),
Expand All @@ -76,6 +80,7 @@ declare module 'astro:content' {
}): E extends keyof DataEntryMap[C]
? Promise<DataEntryMap[C][E]>
: Promise<CollectionEntry<C> | undefined>;

export function getEntry<
C extends keyof ContentEntryMap,
E extends ValidContentEntrySlug<C> | (string & {}),
Expand All @@ -85,6 +90,7 @@ declare module 'astro:content' {
): E extends ValidContentEntrySlug<C>
? Promise<CollectionEntry<C>>
: Promise<CollectionEntry<C> | undefined>;

export function getEntry<
C extends keyof DataEntryMap,
E extends keyof DataEntryMap[C] | (string & {}),
Expand All @@ -102,6 +108,7 @@ declare module 'astro:content' {
slug: ValidContentEntrySlug<C>;
}[],
): Promise<CollectionEntry<C>[]>;

export function getEntries<C extends keyof DataEntryMap>(
entries: {
collection: C;
Expand Down

0 comments on commit 8cfc1c3

Please sign in to comment.