Skip to content

Commit 55c10d1

Browse files
authored
fix: add back code to update user's env.d.ts with proper types (#8214)
1 parent 44bd0cd commit 55c10d1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.changeset/tasty-dragons-smash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Automatically update user's env.d.ts with the proper types to help out migrating away from assets being experimental

packages/astro/src/vite-plugin-inject-env-ts/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ export async function setUpEnvTs({
5050
if (fs.existsSync(envTsPath)) {
5151
let typesEnvContents = await fs.promises.readFile(envTsPath, 'utf-8');
5252

53+
// TODO: Remove this in 4.0, this code is only to help users migrate away from assets being experimental for a long time
54+
if (typesEnvContents.includes('types="astro/client-image"')) {
55+
typesEnvContents = typesEnvContents.replace(
56+
'types="astro/client-image"',
57+
'types="astro/client"'
58+
);
59+
await fs.promises.writeFile(envTsPath, typesEnvContents, 'utf-8');
60+
info(logging, 'assets', `Removed ${bold(envTsPathRelativetoRoot)} types`);
61+
}
62+
5363
if (!fs.existsSync(dotAstroDir))
5464
// Add `.astro` types reference if none exists
5565
return;

0 commit comments

Comments
 (0)