diff --git a/examples/docs/src/config.ts b/examples/docs/src/config.ts index 8ca1b577cfaa..744c93ca1a8c 100644 --- a/examples/docs/src/config.ts +++ b/examples/docs/src/config.ts @@ -42,7 +42,7 @@ export const ALGOLIA = { }; export type Sidebar = Record< - typeof KNOWN_LANGUAGE_CODES[number], + (typeof KNOWN_LANGUAGE_CODES)[number], Record >; export const SIDEBAR: Sidebar = { diff --git a/examples/docs/src/languages.ts b/examples/docs/src/languages.ts index 405b6921ca47..b44d2ba867a6 100644 --- a/examples/docs/src/languages.ts +++ b/examples/docs/src/languages.ts @@ -6,5 +6,5 @@ export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//; export function getLanguageFromURL(pathname: string) { const langCodeMatch = pathname.match(langPathRegex); const langCode = langCodeMatch ? langCodeMatch[1] : 'en'; - return langCode as typeof KNOWN_LANGUAGE_CODES[number]; + return langCode as (typeof KNOWN_LANGUAGE_CODES)[number]; } diff --git a/examples/with-content/src/content/types.generated.d.ts b/examples/with-content/src/content/types.generated.d.ts index 906aabb752f7..a5247b7e4644 100644 --- a/examples/with-content/src/content/types.generated.d.ts +++ b/examples/with-content/src/content/types.generated.d.ts @@ -1,7 +1,7 @@ declare module 'astro:content' { export { z } from 'astro/zod'; export type CollectionEntry = - typeof entryMap[C][keyof typeof entryMap[C]] & Render; + (typeof entryMap)[C][keyof (typeof entryMap)[C]] & Render; type BaseCollectionConfig = { schema?: S; @@ -17,17 +17,17 @@ declare module 'astro:content' { input: BaseCollectionConfig ): BaseCollectionConfig; - export function getEntry( + export function getEntry( collection: C, entryKey: E - ): Promise; + ): Promise<(typeof entryMap)[C][E] & Render>; export function getCollection< C extends keyof typeof entryMap, - E extends keyof typeof entryMap[C] + E extends keyof (typeof entryMap)[C] >( collection: C, - filter?: (data: typeof entryMap[C][E]) => boolean - ): Promise<(typeof entryMap[C][E] & Render)[]>; + filter?: (data: (typeof entryMap)[C][E]) => boolean + ): Promise<((typeof entryMap)[C][E] & Render)[]>; type InferEntrySchema = import('astro/zod').infer< import('astro/zod').ZodObject['schema']> diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 872abeaf8370..a0623f5cd672 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -239,7 +239,7 @@ export interface AstroGlobal = Record = - typeof entryMap[C][keyof typeof entryMap[C]] & Render; + (typeof entryMap)[C][keyof (typeof entryMap)[C]] & Render; type BaseCollectionConfig = { schema?: S; @@ -17,17 +17,17 @@ declare module 'astro:content' { input: BaseCollectionConfig ): BaseCollectionConfig; - export function getEntry( + export function getEntry( collection: C, entryKey: E - ): Promise; + ): Promise<(typeof entryMap)[C][E] & Render>; export function getCollection< C extends keyof typeof entryMap, - E extends keyof typeof entryMap[C] + E extends keyof (typeof entryMap)[C] >( collection: C, - filter?: (data: typeof entryMap[C][E]) => boolean - ): Promise<(typeof entryMap[C][E] & Render)[]>; + filter?: (data: (typeof entryMap)[C][E]) => boolean + ): Promise<((typeof entryMap)[C][E] & Render)[]>; type InferEntrySchema = import('astro/zod').infer< import('astro/zod').ZodObject['schema']> diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index d33690ff8172..c1aa021d52f1 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -613,5 +613,5 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati type ValueOf = T[keyof T]; export type AstroErrorCodes = ValueOf<{ - [T in keyof typeof AstroErrorData]: typeof AstroErrorData[T]['code']; + [T in keyof typeof AstroErrorData]: (typeof AstroErrorData)[T]['code']; }>;