Updating docs for automatic detection of export interface Props
(#1945)
Co-authored-by: Tony Sullivan <tony.sullivan@hyperlab.se>
This commit is contained in:
parent
b8fb80dd2c
commit
72f6d192ce
1 changed files with 5 additions and 2 deletions
|
@ -167,17 +167,20 @@ const { greeting = 'Hello', name } = Astro.props;
|
|||
</div>
|
||||
```
|
||||
|
||||
You can define your props with TypeScript by exporting a `Props` type interface.
|
||||
You can define your props with TypeScript by exporting a `Props` type interface. Astro will automatically pick up any exported `Props` interface and give type warnings/errors for your project.
|
||||
|
||||
> _**In the future**_, Astro will automatically pick up any exported `Props` interface and give type warnings/errors for your project.
|
||||
Make sure to keep all `import` and `export` statements at the top of the component, before any other JavaScript or TypeScript logic!
|
||||
|
||||
```astro
|
||||
---
|
||||
// include any `import` and `export` statements first
|
||||
// Example: <SomeComponent /> (WARNING: "name" prop is required)
|
||||
export interface Props {
|
||||
name: string;
|
||||
greeting?: string;
|
||||
}
|
||||
|
||||
// with `import`s and `export`s out of the way, include the rest of the component logic here
|
||||
const { greeting = 'Hello', name } = Astro.props;
|
||||
---
|
||||
<div>
|
||||
|
|
Loading…
Reference in a new issue