Skip to content
5 changes: 5 additions & 0 deletions .changeset/shy-heads-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': minor
---

Add a new SvgComponent type and update SVG module declaration
5 changes: 2 additions & 3 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ declare module '*.avif' {
export default metadata;
}
declare module '*.svg' {
type Props = astroHTML.JSX.SVGAttributes;

const Component: ((_props: Props) => any) & ImageMetadata;
type SvgComponent = import('./dist/assets/types.js').SvgComponent;
const Component: SvgComponent & ImageMetadata;
export default Component;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/astro/src/assets/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type * as astroHTML from 'astro/jsx-runtime';
import type { OmitPreservingIndexSignature, Simplify, WithRequired } from '../type-utils.js';
import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
import type { ImageService } from './services/service.js';
Expand Down Expand Up @@ -284,3 +285,5 @@ export type RemoteImageProps<T> =
*/
inferSize?: false | undefined;
});

export type SvgComponent = (props: astroHTML.JSX.SVGAttributes) => any;
1 change: 1 addition & 0 deletions packages/astro/src/types/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type {
ImageQuality,
ImageQualityPreset,
ImageTransform,
SvgComponent,
UnresolvedImageTransform,
} from '../../assets/types.js';
export type { AssetsPrefix, SSRManifest } from '../../core/app/types.js';
Expand Down
Loading