fix: declare namespace so client-base.d.ts stays an ambient definition (#7009)

This commit is contained in:
Erika 2023-05-05 16:20:37 +02:00 committed by GitHub
parent 5182689086
commit 1d4db68e64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix types from `astro/client` not working properly due to `client-base.d.ts` being an non-ambient declaration file

View file

@ -389,7 +389,7 @@ declare module '*?inline' {
}
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace App {
declare namespace App {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Locals {}
}

View file

@ -2,6 +2,7 @@ import fs from 'node:fs';
import { basename, join } from 'node:path/posix';
import type { StaticBuildOptions } from '../core/build/types.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { warn } from '../core/logger/core.js';
import { prependForwardSlash } from '../core/path.js';
import { isLocalService, type ImageService, type LocalImageService } from './services/service.js';
import type { GetImageResult, ImageMetadata, ImageTransform } from './types.js';
@ -103,9 +104,10 @@ export async function generateImage(
try {
await fs.promises.mkdir(assetsCacheDir, { recursive: true });
} catch (err) {
console.error(
'An error was encountered while creating the cache directory. Proceeding without caching. Error: ',
err
warn(
buildOpts.logging,
'astro:assets',
`An error was encountered while creating the cache directory. Proceeding without caching. Error: ${err}`
);
useCache = false;
}
@ -160,9 +162,10 @@ export async function generateImage(
await fs.promises.writeFile(cachedFileURL, resultData.data);
await fs.promises.copyFile(cachedFileURL, finalFileURL);
} catch (e) {
console.error(
`There was an error creating the cache entry for ${filepath}. Attempting to write directly to output directory. Error: `,
e
warn(
buildOpts.logging,
'astro:assets',
`An error was encountered while creating the cache directory. Proceeding without caching. Error: ${e}`
);
await fs.promises.writeFile(finalFileURL, resultData.data);
}