diff --git a/.gitignore b/.gitignore index ac9d09788..28dd70cdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store +.astro dist node_modules diff --git a/docs/.astro/types.d.ts b/docs/.astro/types.d.ts deleted file mode 100644 index becd0126b..000000000 --- a/docs/.astro/types.d.ts +++ /dev/null @@ -1,173 +0,0 @@ -declare module 'astro:content' { - interface Render { - '.md': Promise<{ - Content: import('astro').MarkdownInstance<{}>['Content']; - headings: import('astro').MarkdownHeading[]; - remarkPluginFrontmatter: Record; - }>; - } -} - -declare module 'astro:content' { - export { z } from 'astro/zod'; - export type CollectionEntry = - (typeof entryMap)[C][keyof (typeof entryMap)[C]]; - - // TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04 - /** - * @deprecated - * `astro:content` no longer provide `image()`. - * - * Please use it through `schema`, like such: - * ```ts - * import { defineCollection, z } from "astro:content"; - * - * defineCollection({ - * schema: ({ image }) => - * z.object({ - * image: image(), - * }), - * }); - * ``` - */ - export const image: never; - - // This needs to be in sync with ImageMetadata - export type ImageFunction = () => import('astro/zod').ZodObject<{ - src: import('astro/zod').ZodString; - width: import('astro/zod').ZodNumber; - height: import('astro/zod').ZodNumber; - format: import('astro/zod').ZodUnion< - [ - import('astro/zod').ZodLiteral<'png'>, - import('astro/zod').ZodLiteral<'jpg'>, - import('astro/zod').ZodLiteral<'jpeg'>, - import('astro/zod').ZodLiteral<'tiff'>, - import('astro/zod').ZodLiteral<'webp'>, - import('astro/zod').ZodLiteral<'gif'>, - import('astro/zod').ZodLiteral<'svg'> - ] - >; - }>; - - type BaseSchemaWithoutEffects = - | import('astro/zod').AnyZodObject - | import('astro/zod').ZodUnion - | import('astro/zod').ZodDiscriminatedUnion - | import('astro/zod').ZodIntersection< - import('astro/zod').AnyZodObject, - import('astro/zod').AnyZodObject - >; - - type BaseSchema = - | BaseSchemaWithoutEffects - | import('astro/zod').ZodEffects; - - export type SchemaContext = { image: ImageFunction }; - - type BaseCollectionConfig = { - schema?: S | ((context: SchemaContext) => S); - }; - export function defineCollection( - input: BaseCollectionConfig - ): BaseCollectionConfig; - - type EntryMapKeys = keyof typeof entryMap; - type AllValuesOf = T extends any ? T[keyof T] : never; - type ValidEntrySlug = AllValuesOf<(typeof entryMap)[C]>['slug']; - - export function getEntryBySlug< - C extends keyof typeof entryMap, - E extends ValidEntrySlug | (string & {}) - >( - collection: C, - // Note that this has to accept a regular string too, for SSR - entrySlug: E - ): E extends ValidEntrySlug - ? Promise> - : Promise | undefined>; - export function getCollection>( - collection: C, - filter?: (entry: CollectionEntry) => entry is E - ): Promise; - export function getCollection( - collection: C, - filter?: (entry: CollectionEntry) => unknown - ): Promise[]>; - - type ReturnTypeOrOriginal = T extends (...args: any[]) => infer R ? R : T; - type InferEntrySchema = import('astro/zod').infer< - ReturnTypeOrOriginal['schema']> - >; - - const entryMap: { - "docs": { -"about.md": { - id: "about.md", - slug: "about", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"advanced.md": { - id: "advanced.md", - slug: "advanced", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"cli.md": { - id: "cli.md", - slug: "cli", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"introduction.md": { - id: "introduction.md", - slug: "introduction", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"node.md": { - id: "node.md", - slug: "node", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"openapi-fetch/about.md": { - id: "openapi-fetch/about.md", - slug: "openapi-fetch/about", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"openapi-fetch/api.md": { - id: "openapi-fetch/api.md", - slug: "openapi-fetch/api", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"openapi-fetch/examples.md": { - id: "openapi-fetch/examples.md", - slug: "openapi-fetch/examples", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -"openapi-fetch/index.md": { - id: "openapi-fetch/index.md", - slug: "openapi-fetch", - body: string, - collection: "docs", - data: InferEntrySchema<"docs"> -} & { render(): Render[".md"] }, -}, - - }; - - type ContentConfig = typeof import("../src/content/config"); -} diff --git a/docs/package.json b/docs/package.json index 83b20c332..06a75e29f 100644 --- a/docs/package.json +++ b/docs/package.json @@ -22,6 +22,7 @@ "sass": "^1.62.1" }, "devDependencies": { - "html-escaper": "^3.0.3" + "html-escaper": "^3.0.3", + "typescript": "^5.0.4" } } diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 6d7d37302..955f00483 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -1,10 +1,13 @@ { - "extends": "../tsconfig.json", "compilerOptions": { "baseUrl": ".", + "esModuleInterop": true, "jsx": "preserve", + "module": "NodeNext", + "moduleResolution": "NodeNext", "outDir": "dist", "skipLibCheck": true, - "strict": true + "strict": true, + "target": "ESNext" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5af50ba56..b61fac519 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -68,6 +68,9 @@ importers: html-escaper: specifier: ^3.0.3 version: 3.0.3 + typescript: + specifier: ^5.0.4 + version: 5.0.4 packages/openapi-typescript: dependencies: