fix(assets): Fix misc types issues (#8568)

* fix(assets): Fix misc types issues

* fix: remove unnecessary change

* chore: changeset
This commit is contained in:
Erika 2023-09-18 11:39:21 +02:00 committed by GitHub
parent 8d361169b8
commit 95b5f6280d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix small types issues related to `astro:assets`'s AVIF support and `getImage`

View file

@ -48,9 +48,7 @@ declare module 'astro:assets' {
* This is functionally equivalent to using the `<Image />` component, as the component calls this function internally. * This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
*/ */
getImage: ( getImage: (
options: options: import('./dist/assets/types.js').UnresolvedImageTransform
| import('./dist/assets/types.js').ImageTransform
| import('./dist/assets/types.js').UnresolvedImageTransform
) => Promise<import('./dist/assets/types.js').GetImageResult>; ) => Promise<import('./dist/assets/types.js').GetImageResult>;
imageConfig: import('./dist/@types/astro.js').AstroConfig['image']; imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService; getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;

View file

@ -33,6 +33,7 @@ declare module 'astro:content' {
import('astro/zod').ZodLiteral<'webp'>, import('astro/zod').ZodLiteral<'webp'>,
import('astro/zod').ZodLiteral<'gif'>, import('astro/zod').ZodLiteral<'gif'>,
import('astro/zod').ZodLiteral<'svg'>, import('astro/zod').ZodLiteral<'svg'>,
import('astro/zod').ZodLiteral<'avif'>,
] ]
>; >;
}>; }>;

View file

@ -48,6 +48,7 @@ export type {
ImageQuality, ImageQuality,
ImageQualityPreset, ImageQualityPreset,
ImageTransform, ImageTransform,
UnresolvedImageTransform,
} from '../assets/types.js'; } from '../assets/types.js';
export type { RemotePattern } from '../assets/utils/remotePattern.js'; export type { RemotePattern } from '../assets/utils/remotePattern.js';
export type { SSRManifest } from '../core/app/types.js'; export type { SSRManifest } from '../core/app/types.js';

View file

@ -67,7 +67,7 @@ export async function getConfiguredImageService(): Promise<ImageService> {
} }
export async function getImage( export async function getImage(
options: ImageTransform | UnresolvedImageTransform, options: UnresolvedImageTransform,
imageConfig: AstroConfig['image'] imageConfig: AstroConfig['image']
): Promise<GetImageResult> { ): Promise<GetImageResult> {
if (!options || typeof options !== 'object') { if (!options || typeof options !== 'object') {

View file

@ -28,8 +28,11 @@ export interface ImageMetadata {
orientation?: number; orientation?: number;
} }
/**
* A yet to be resolved image transform. Used by `getImage`
*/
export type UnresolvedImageTransform = Omit<ImageTransform, 'src'> & { export type UnresolvedImageTransform = Omit<ImageTransform, 'src'> & {
src: Promise<{ default: ImageMetadata }>; src: ImageMetadata | string | Promise<{ default: ImageMetadata }>;
}; };
/** /**