Skip to content

Commit

Permalink
Add note about astroHTML in .ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Jul 15, 2022
1 parent 7257fb2 commit 99fa11a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pages/en/guides/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ declare namespace astroHTML.JSX {
}
```

:::note
`astroHTML` is injected globally inside `.astro` components. To use it in TypeScript files, use a [triple-slash directive](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html):

```ts
/// <reference types="astro/astro-jsx" />

type MyAttributes = astroHTML.JSX.ImgHTMLAttributes;
```
:::

## Type checking

To see type errors in your editor, please make sure that you have the [Astro VS Code extension](/en/editor-setup/) installed. Please note that the `astro start` and `astro build` commands will transpile the code with esbuild, but will not run any type checking. To prevent your code from building if it contains TypeScript errors, change your "build" script in `package.json` to the following:
Expand Down

0 comments on commit 99fa11a

Please sign in to comment.