From 519a5d84d141848817846fe9fd5f4d3e838cbc55 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Thu, 3 Mar 2022 12:34:04 -0500 Subject: [PATCH] Add .d.ts file to astro package for language-tools consumption (#2711) * Add .d.ts file for user and language-server consumption * Update according to feedback --- packages/astro/env.d.ts | 12 ++++++++++++ packages/astro/package.json | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 packages/astro/env.d.ts diff --git a/packages/astro/env.d.ts b/packages/astro/env.d.ts new file mode 100644 index 0000000000..88a4bcce35 --- /dev/null +++ b/packages/astro/env.d.ts @@ -0,0 +1,12 @@ +/// + +type Astro = import('./dist/types/@types/astro').AstroGlobal; + +// We duplicate the description here because editors won't show the JSDoc comment from the imported type (but will for its properties, ex: Astro.request will show the AstroGlobal.request description) +/** + * Astro.* available in all components + * Docs: https://docs.astro.build/reference/api-reference/#astro-global + */ +declare const Astro: Readonly; + +declare const Fragment: any; diff --git a/packages/astro/package.json b/packages/astro/package.json index dde3807917..63c19bf73d 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -15,6 +15,7 @@ "types": "./dist/types/@types/astro.d.ts", "exports": { ".": "./astro.js", + "./env": "./env.d.ts", "./app/node": "./dist/core/app/node.js", "./client/*": "./dist/runtime/client/*", "./components": "./components/index.js", @@ -44,6 +45,7 @@ "components", "dist", "astro.js", + "env.d.ts", "README.md", "vendor" ],