Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(assets): Fix misc types issues #8568

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 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 All @@ -62,12 +60,8 @@ declare module 'astro:assets' {
'alt'
>;

export type LocalImageProps = import('./dist/type-utils.js').Simplify<
import('./dist/assets/types.js').LocalImageProps<ImgAttributes>
>;
export type RemoteImageProps = import('./dist/type-utils.js').Simplify<
import('./dist/assets/types.js').RemoteImageProps<ImgAttributes>
>;
export type LocalImageProps = import('./dist/assets/types.js').LocalImageProps<ImgAttributes>;
export type RemoteImageProps = import('./dist/assets/types.js').RemoteImageProps<ImgAttributes>;
export const { getImage, getConfiguredImageService, imageConfig, Image }: AstroAssets;
}

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
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
Loading