fix: add back code to update user's env.d.ts with proper types (#8214)

This commit is contained in:
Erika 2023-08-24 15:55:11 +02:00 committed by GitHub
parent 44bd0cd825
commit 55c10d1d56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -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

View file

@ -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;