Skip to content

Commit

Permalink
fix: add back code to update user's env.d.ts with proper types (#8214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored Aug 24, 2023
1 parent 44bd0cd commit 55c10d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-dragons-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental
10 changes: 10 additions & 0 deletions packages/astro/src/vite-plugin-inject-env-ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ export async function setUpEnvTs({
if (fs.existsSync(envTsPath)) {
let typesEnvContents = await fs.promises.readFile(envTsPath, 'utf-8');

// TODO: Remove this in 4.0, this code is only to help users migrate away from assets being experimental for a long time
if (typesEnvContents.includes('types="astro/client-image"')) {
typesEnvContents = typesEnvContents.replace(
'types="astro/client-image"',
'types="astro/client"'
);
await fs.promises.writeFile(envTsPath, typesEnvContents, 'utf-8');
info(logging, 'assets', `Removed ${bold(envTsPathRelativetoRoot)} types`);
}

if (!fs.existsSync(dotAstroDir))
// Add `.astro` types reference if none exists
return;
Expand Down

0 comments on commit 55c10d1

Please sign in to comment.