Skip to content

Commit

Permalink
fix(assets): Fix misc types issues (#8568)
Browse files Browse the repository at this point in the history
* fix(assets): Fix misc types issues

* fix: remove unnecessary change

* chore: changeset
  • Loading branch information
Princesseuh committed Sep 18, 2023
1 parent 8d36116 commit 95b5f62
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-teachers-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix small types issues related to `astro:assets`'s AVIF support and `getImage`
4 changes: 1 addition & 3 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/astro/content-types.template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'>,
]
>;
}>;
Expand Down
1 change: 1 addition & 0 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/assets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>;
};

/**
Expand Down

0 comments on commit 95b5f62

Please sign in to comment.