summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@matthewphillips.info> 2021-09-01 12:49:01 -0700
committerGravatar GitHub <noreply@github.com> 2021-09-01 15:49:01 -0400
commit231964f084ba1f553d3a6455ea6e034cdf3d00c3 (patch)
tree4bef17f975c74a0ab8b5c43909ff959b5c0f0465
parentfba0446666495055fffcdd5d10b6715703308e48 (diff)
downloadastro-231964f084ba1f553d3a6455ea6e034cdf3d00c3.tar.gz
astro-231964f084ba1f553d3a6455ea6e034cdf3d00c3.tar.zst
astro-231964f084ba1f553d3a6455ea6e034cdf3d00c3.zip
Add interfaces for built-in components (#1292)
* Add interfaces for built-in components * Adds a changeset
-rw-r--r--.changeset/perfect-kids-occur.md5
-rw-r--r--packages/astro/components/Markdown.astro11
-rw-r--r--packages/astro/components/Prism.astro9
3 files changed, 23 insertions, 2 deletions
diff --git a/.changeset/perfect-kids-occur.md b/.changeset/perfect-kids-occur.md
new file mode 100644
index 000000000..7617cdcd4
--- /dev/null
+++ b/.changeset/perfect-kids-occur.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Adds interfaces for built-in components
diff --git a/packages/astro/components/Markdown.astro b/packages/astro/components/Markdown.astro
index f2e4f3335..b2639804d 100644
--- a/packages/astro/components/Markdown.astro
+++ b/packages/astro/components/Markdown.astro
@@ -1,7 +1,16 @@
---
import { renderMarkdown } from '@astrojs/markdown-support';
-const { content, $scope } = Astro.props;
+export interface Props {
+ content?: string;
+}
+
+// Internal props that should not be part of the external interface.
+interface InternalProps extends Props {
+ $scope: string;
+}
+
+const { content, $scope } = Astro.props as InternalProps;
let html = null;
// This flow is only triggered if a user passes `<Markdown content={content} />`
diff --git a/packages/astro/components/Prism.astro b/packages/astro/components/Prism.astro
index 6aaffbe74..ba4b22ec3 100644
--- a/packages/astro/components/Prism.astro
+++ b/packages/astro/components/Prism.astro
@@ -3,7 +3,14 @@ import Prism from 'prismjs';
import { addAstro } from '@astrojs/prism';
import loadLanguages from 'prismjs/components/index.js';
-const { class: className, lang, code } = Astro.props;
+export interface Props {
+ class?: string;
+ lang?: string;
+ code: string;
+}
+
+const { class: className, lang, code } = Astro.props as Props;
+
let classLanguage = `language-${lang}`
const languageMap = new Map([