summaryrefslogtreecommitdiff
path: root/docs/src
diff options
context:
space:
mode:
authorGravatar Tony Sullivan <tony.f.sullivan@outlook.com> 2021-11-20 17:53:31 +0100
committerGravatar GitHub <noreply@github.com> 2021-11-20 10:53:31 -0600
commit72f6d192ced5a40cae1761a826115c7740933ded (patch)
tree25d28a2e2874dcae8cab4b7dae238adc684624de /docs/src
parentb8fb80dd2c040d37bbe8f5e21ced9486a3017ca8 (diff)
downloadastro-72f6d192ced5a40cae1761a826115c7740933ded.tar.gz
astro-72f6d192ced5a40cae1761a826115c7740933ded.tar.zst
astro-72f6d192ced5a40cae1761a826115c7740933ded.zip
Updating docs for automatic detection of `export interface Props` (#1945)
Co-authored-by: Tony Sullivan <tony.sullivan@hyperlab.se>
Diffstat (limited to 'docs/src')
-rw-r--r--docs/src/pages/core-concepts/astro-components.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/src/pages/core-concepts/astro-components.md b/docs/src/pages/core-concepts/astro-components.md
index 1f1ae9a4a..84715de7d 100644
--- a/docs/src/pages/core-concepts/astro-components.md
+++ b/docs/src/pages/core-concepts/astro-components.md
@@ -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>