Skip to content

Commit

Permalink
Implicit element types (#5098)
Browse files Browse the repository at this point in the history
* Separate arbitrary intrinsic element definition

* Create changeset
  • Loading branch information
jkjustjoshing authored Oct 18, 2022
1 parent 66e8ae3 commit f684e9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-dodos-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Separate type definitions for built-in HTML elements and custom elements. Helpful when implementing an "as" prop similar to [styled-components](https://styled-components.com/docs/api#as-polymorphic-prop).
8 changes: 5 additions & 3 deletions packages/astro/astro-jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ declare namespace astroHTML.JSX {
zoomAndPan?: string | undefined | null;
}

interface IntrinsicElements {
interface DefinedIntrinsicElements {
// HTML
a: AnchorHTMLAttributes;
abbr: HTMLAttributes;
Expand Down Expand Up @@ -1461,8 +1461,10 @@ declare namespace astroHTML.JSX {
tspan: SVGAttributes;
use: SVGAttributes;
view: SVGAttributes;
}

// Allow for arbitrary elements
[name: string]: { [name: string]: any };
interface IntrinsicElements extends DefinedIntrinsicElements {
// Allow for arbitrary elements
[name: string]: { [name: string]: any };
}
}

0 comments on commit f684e9d

Please sign in to comment.