fix(assets): Fix misc types issues (#8568)
* fix(assets): Fix misc types issues * fix: remove unnecessary change * chore: changeset
This commit is contained in:
parent
8d361169b8
commit
95b5f6280d
6 changed files with 13 additions and 5 deletions
5
.changeset/fair-teachers-protect.md
Normal file
5
.changeset/fair-teachers-protect.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix small types issues related to `astro:assets`'s AVIF support and `getImage`
|
4
packages/astro/client.d.ts
vendored
4
packages/astro/client.d.ts
vendored
|
@ -48,9 +48,7 @@ declare module 'astro:assets' {
|
|||
* This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
|
||||
*/
|
||||
getImage: (
|
||||
options:
|
||||
| import('./dist/assets/types.js').ImageTransform
|
||||
| import('./dist/assets/types.js').UnresolvedImageTransform
|
||||
options: import('./dist/assets/types.js').UnresolvedImageTransform
|
||||
) => Promise<import('./dist/assets/types.js').GetImageResult>;
|
||||
imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
|
||||
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
|
||||
|
|
1
packages/astro/content-types.template.d.ts
vendored
1
packages/astro/content-types.template.d.ts
vendored
|
@ -33,6 +33,7 @@ declare module 'astro:content' {
|
|||
import('astro/zod').ZodLiteral<'webp'>,
|
||||
import('astro/zod').ZodLiteral<'gif'>,
|
||||
import('astro/zod').ZodLiteral<'svg'>,
|
||||
import('astro/zod').ZodLiteral<'avif'>,
|
||||
]
|
||||
>;
|
||||
}>;
|
||||
|
|
|
@ -48,6 +48,7 @@ export type {
|
|||
ImageQuality,
|
||||
ImageQualityPreset,
|
||||
ImageTransform,
|
||||
UnresolvedImageTransform,
|
||||
} from '../assets/types.js';
|
||||
export type { RemotePattern } from '../assets/utils/remotePattern.js';
|
||||
export type { SSRManifest } from '../core/app/types.js';
|
||||
|
|
|
@ -67,7 +67,7 @@ export async function getConfiguredImageService(): Promise<ImageService> {
|
|||
}
|
||||
|
||||
export async function getImage(
|
||||
options: ImageTransform | UnresolvedImageTransform,
|
||||
options: UnresolvedImageTransform,
|
||||
imageConfig: AstroConfig['image']
|
||||
): Promise<GetImageResult> {
|
||||
if (!options || typeof options !== 'object') {
|
||||
|
|
|
@ -28,8 +28,11 @@ export interface ImageMetadata {
|
|||
orientation?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A yet to be resolved image transform. Used by `getImage`
|
||||
*/
|
||||
export type UnresolvedImageTransform = Omit<ImageTransform, 'src'> & {
|
||||
src: Promise<{ default: ImageMetadata }>;
|
||||
src: ImageMetadata | string | Promise<{ default: ImageMetadata }>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue