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

Add a new `SvgComponent` type

Until now, getting the type of an SVG component was not really straight forward. You can now directly import the `SVGComponent` from `astro/types` instead:

```diff
-type SvgComponent = typeof import("*.svg")
+import type { SvgComponent } from "astro/types"
```
4 changes: 1 addition & 3 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ declare module '*.avif' {
export default metadata;
}
declare module '*.svg' {
type Props = astroHTML.JSX.SVGAttributes;

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

Expand Down
2 changes: 2 additions & 0 deletions packages/astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export type Polymorphic<P extends { as: HTMLTag }> = PolymorphicAttributes<
>;

export type ComponentProps<T extends (args: any) => any> = Simplify<Parameters<T>[0]>;

export type SvgComponent = (props: astroHTML.JSX.SVGAttributes) => any;
Loading