From 22ce8cb2fa0bd845056f89360ee518d07a87c163 Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 23 May 2023 12:56:52 +0200 Subject: [PATCH 1/5] fix: Fix bad InputFormat type --- packages/astro/client-image.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/client-image.d.ts b/packages/astro/client-image.d.ts index 5148014a4a87..ffcc1c63c95f 100644 --- a/packages/astro/client-image.d.ts +++ b/packages/astro/client-image.d.ts @@ -2,7 +2,7 @@ // TODO: Merge this file with `client-base.d.ts` in 3.0, when the `astro:assets` feature isn't under a flag anymore. -type InputFormat = import('./dist/assets/types.js').InputFormat; +type InputFormat = import('./dist/assets/types.js').ImageInputFormat; interface ImageMetadata { src: string; From 04fb9bb674ba474094c33d2cc8bdffa22aa7bd27 Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 23 May 2023 12:57:10 +0200 Subject: [PATCH 2/5] fix: duplicated ico type --- packages/astro/client.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 44da8654b420..96f59d5868a0 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -21,10 +21,6 @@ declare module '*.svg' { const src: string; export default src; } -declare module '*.ico' { - const src: string; - export default src; -} declare module '*.webp' { const src: string; export default src; From c2d6bcf987a4365383966a5ebd66dca0afeb665b Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 23 May 2023 12:57:37 +0200 Subject: [PATCH 3/5] feat: add types and docs for base import.meta.env values --- packages/astro/client-base.d.ts | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/astro/client-base.d.ts b/packages/astro/client-base.d.ts index 5186468c8571..37bae7b1c6ae 100644 --- a/packages/astro/client-base.d.ts +++ b/packages/astro/client-base.d.ts @@ -1,5 +1,32 @@ /// +// eslint-disable-next-line @typescript-eslint/no-namespace +declare namespace App { + // eslint-disable-next-line @typescript-eslint/no-empty-interface + export interface Locals {} +} + +interface ImportMetaEnv { + /** + * The prefix for Astro-generated asset links if the build.assetsPrefix config option is set. This can be used to create asset links not handled by Astro. + */ + readonly ASSETS_PREFIX: string; + /** + * This is set to the site option specified in your project’s Astro config file. + */ + readonly SITE: string; +} + +interface ImportMeta { + /** + * Astro and Vite expose environment variables through `import.meta.env`. For a complete list of the environment variables available, see the two references below. + * + * - [Astro reference](https://docs.astro.build/en/guides/environment-variables/#default-environment-variables) + * - [Vite reference](https://vitejs.dev/guide/env-and-mode.html#env-variables) + */ + readonly env: ImportMetaEnv; +} + declare module 'astro:assets' { // Exporting things one by one is a bit cumbersome, not sure if there's a better way - erika, 2023-02-03 type AstroAssets = { @@ -387,9 +414,3 @@ declare module '*?inline' { const src: string; export default src; } - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace App { - // eslint-disable-next-line @typescript-eslint/no-empty-interface - export interface Locals {} -} From 8483f87cf76b5de4b0f8908061fecfe7a7a92ef4 Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 23 May 2023 12:57:49 +0200 Subject: [PATCH 4/5] fix: update import-meta with latest info --- packages/astro/import-meta.d.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/astro/import-meta.d.ts b/packages/astro/import-meta.d.ts index 2b05d0a6511e..23d951cf2db1 100644 --- a/packages/astro/import-meta.d.ts +++ b/packages/astro/import-meta.d.ts @@ -1,4 +1,4 @@ -// File vendored from Vite itself, as a workaround to https://github.com/vitejs/vite/pull/9827 until Vite 4 comes out +// File vendored from Vite itself, as a workaround to https://github.com/vitejs/vite/issues/13309 until Vite 5 comes out // This file is an augmentation to the built-in ImportMeta interface // Thus cannot contain any top-level imports @@ -6,13 +6,6 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ -// Duplicate of import('../src/node/importGlob').GlobOptions in order to -// avoid breaking the production client type. Because this file is referenced -// in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist. -interface GlobOptions { - as?: string; -} - interface ImportMeta { url: string; From 27ee560604305065f7b45b96e2a7741cfd225eb1 Mon Sep 17 00:00:00 2001 From: Princesseuh Date: Tue, 23 May 2023 12:58:40 +0200 Subject: [PATCH 5/5] chore: changeset --- .changeset/hungry-lobsters-happen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hungry-lobsters-happen.md diff --git a/.changeset/hungry-lobsters-happen.md b/.changeset/hungry-lobsters-happen.md new file mode 100644 index 000000000000..00ef925841c0 --- /dev/null +++ b/.changeset/hungry-lobsters-happen.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Add types for `import.meta.env.ASSETS_PREFIX` and `import.meta.env.SITE`