Add types for import.meta.env.ASSETS_PREFIX
and import.meta.env.SITE
(#7172)
This commit is contained in:
parent
5b6a0312a8
commit
2ca94269ed
5 changed files with 34 additions and 19 deletions
5
.changeset/hungry-lobsters-happen.md
Normal file
5
.changeset/hungry-lobsters-happen.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add types for `import.meta.env.ASSETS_PREFIX` and `import.meta.env.SITE`
|
33
packages/astro/client-base.d.ts
vendored
33
packages/astro/client-base.d.ts
vendored
|
@ -1,5 +1,32 @@
|
||||||
/// <reference path="./import-meta.d.ts" />
|
/// <reference path="./import-meta.d.ts" />
|
||||||
|
|
||||||
|
// 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' {
|
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
|
// Exporting things one by one is a bit cumbersome, not sure if there's a better way - erika, 2023-02-03
|
||||||
type AstroAssets = {
|
type AstroAssets = {
|
||||||
|
@ -387,9 +414,3 @@ declare module '*?inline' {
|
||||||
const src: string;
|
const src: string;
|
||||||
export default src;
|
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 {}
|
|
||||||
}
|
|
||||||
|
|
2
packages/astro/client-image.d.ts
vendored
2
packages/astro/client-image.d.ts
vendored
|
@ -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.
|
// 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 {
|
interface ImageMetadata {
|
||||||
src: string;
|
src: string;
|
||||||
|
|
4
packages/astro/client.d.ts
vendored
4
packages/astro/client.d.ts
vendored
|
@ -21,10 +21,6 @@ declare module '*.svg' {
|
||||||
const src: string;
|
const src: string;
|
||||||
export default src;
|
export default src;
|
||||||
}
|
}
|
||||||
declare module '*.ico' {
|
|
||||||
const src: string;
|
|
||||||
export default src;
|
|
||||||
}
|
|
||||||
declare module '*.webp' {
|
declare module '*.webp' {
|
||||||
const src: string;
|
const src: string;
|
||||||
export default src;
|
export default src;
|
||||||
|
|
9
packages/astro/import-meta.d.ts
vendored
9
packages/astro/import-meta.d.ts
vendored
|
@ -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
|
// This file is an augmentation to the built-in ImportMeta interface
|
||||||
// Thus cannot contain any top-level imports
|
// Thus cannot contain any top-level imports
|
||||||
|
@ -6,13 +6,6 @@
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/consistent-type-imports */
|
/* 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 {
|
interface ImportMeta {
|
||||||
url: string;
|
url: string;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue