You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is very advanced usage, nonetheless we see some people do it. Notably, our official image integration use them to provide img props completions and type checking in the components
Using them is done through a triple slash directive, this works both in Astro files and in TypeScript files
---/// <referencetypes="astro/astro-jsx" />// Access them directly:exporttypeProps=astroHTML.JSX.ImgHTMLAttributes;---
<img ...>
Extending them is done through a .d.ts file redeclaring the namespace:
People tend to extend them whenever they want non-standard attributes while still having typechecking. Another case is when we made a mistake and some attributes isn't included in our definitions 😅
The text was updated successfully, but these errors were encountered:
Maybe we can add this to our Typescript page? Are there other use cases for triple-slash directives augmenting ambient types we would want to mention and does it matter where .d.ts are?
delucis
added
the
add new content
Document something that is not in docs. May require testing, confirmation, or affect other pages.
label
Jul 14, 2022
Maybe we can add this to our Typescript page? Are there other use cases for triple-slash directives augmenting ambient types we would want to mention and does it matter where .d.ts are?
I do not think there's other use cases specific to Astro and it shouldn't matter where the .d.ts is in this case, though I have heard of issues when using a folder called "types" in the past
* Document use of Astro’s JSX types
Closes#984
* Use new element-specific interface
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
* Add note about `astroHTML` in `.ts` files
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
This is very advanced usage, nonetheless we see some people do it. Notably, our official image integration use them to provide
img
props completions and type checking in the componentsUsing them is done through a triple slash directive, this works both in Astro files and in TypeScript files
Extending them is done through a .d.ts file redeclaring the namespace:
People tend to extend them whenever they want non-standard attributes while still having typechecking. Another case is when we made a mistake and some attributes isn't included in our definitions 😅
The text was updated successfully, but these errors were encountered: