From 231964f084ba1f553d3a6455ea6e034cdf3d00c3 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 1 Sep 2021 12:49:01 -0700 Subject: [PATCH] Add interfaces for built-in components (#1292) * Add interfaces for built-in components * Adds a changeset --- .changeset/perfect-kids-occur.md | 5 +++++ packages/astro/components/Markdown.astro | 11 ++++++++++- packages/astro/components/Prism.astro | 9 ++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/perfect-kids-occur.md diff --git a/.changeset/perfect-kids-occur.md b/.changeset/perfect-kids-occur.md new file mode 100644 index 0000000000..7617cdcd4d --- /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 f2e4f33357..b2639804da 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 `` diff --git a/packages/astro/components/Prism.astro b/packages/astro/components/Prism.astro index 6aaffbe741..ba4b22ec39 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([