fix: add back code to update user's env.d.ts with proper types (#8214)
This commit is contained in:
parent
44bd0cd825
commit
55c10d1d56
2 changed files with 15 additions and 0 deletions
5
.changeset/tasty-dragons-smash.md
Normal file
5
.changeset/tasty-dragons-smash.md
Normal 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
|
|
@ -50,6 +50,16 @@ export async function setUpEnvTs({
|
||||||
if (fs.existsSync(envTsPath)) {
|
if (fs.existsSync(envTsPath)) {
|
||||||
let typesEnvContents = await fs.promises.readFile(envTsPath, 'utf-8');
|
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))
|
if (!fs.existsSync(dotAstroDir))
|
||||||
// Add `.astro` types reference if none exists
|
// Add `.astro` types reference if none exists
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue