diff --git a/.changeset/cuddly-moons-hang.md b/.changeset/cuddly-moons-hang.md new file mode 100644 index 0000000000..c726f5aa43 --- /dev/null +++ b/.changeset/cuddly-moons-hang.md @@ -0,0 +1,14 @@ +--- +"astro": minor +--- + +Adds a new `ComponentProps` type export from `astro/types` to get the props type of an Astro component. + +```astro +--- +import type { ComponentProps } from 'astro/types'; +import { Button } from "./Button.astro"; + +type myButtonProps = ComponentProps; +--- +``` diff --git a/packages/astro/types.d.ts b/packages/astro/types.d.ts index 638ad762e8..7eaa4823c6 100644 --- a/packages/astro/types.d.ts +++ b/packages/astro/types.d.ts @@ -1,5 +1,6 @@ import './astro-jsx'; -import { AstroBuiltinAttributes } from './dist/@types/astro.js'; +import type { AstroBuiltinAttributes } from './dist/@types/astro.js'; +import type { Simplify } from './dist/type-utils.js'; /** Any supported HTML or SVG element name, as defined by the HTML specification */ export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements; @@ -20,3 +21,5 @@ type PolymorphicAttributes

= Omit

= PolymorphicAttributes< Omit & { as: NonNullable } >; + +export type ComponentProps any> = Simplify[0]>;