diff --git a/.changeset/perfect-melons-wonder.md b/.changeset/perfect-melons-wonder.md
new file mode 100644
index 000000000000..0c45ce87dd37
--- /dev/null
+++ b/.changeset/perfect-melons-wonder.md
@@ -0,0 +1,5 @@
+---
+'astro': minor
+---
+
+Make type definitions available through package.json exports
diff --git a/packages/astro/astro-jsx.d.ts b/packages/astro/astro-jsx.d.ts
index bdf6b6aa22c8..27a37bd423b4 100644
--- a/packages/astro/astro-jsx.d.ts
+++ b/packages/astro/astro-jsx.d.ts
@@ -23,12 +23,12 @@ declare namespace astroHTML.JSX {
children?: Children;
}
- type AstroBuiltinProps = import('./dist/types/@types/astro').AstroBuiltinProps;
- type AstroBuiltinAttributes = import('./dist/types/@types/astro').AstroBuiltinAttributes;
- type AstroDefineVarsAttribute = import('./dist/types/@types/astro').AstroDefineVarsAttribute;
- type AstroScriptAttributes = import('./dist/types/@types/astro').AstroScriptAttributes &
+ type AstroBuiltinProps = import('./dist/@types/astro').AstroBuiltinProps;
+ type AstroBuiltinAttributes = import('./dist/@types/astro').AstroBuiltinAttributes;
+ type AstroDefineVarsAttribute = import('./dist/@types/astro').AstroDefineVarsAttribute;
+ type AstroScriptAttributes = import('./dist/@types/astro').AstroScriptAttributes &
AstroDefineVarsAttribute;
- type AstroStyleAttributes = import('./dist/types/@types/astro').AstroStyleAttributes &
+ type AstroStyleAttributes = import('./dist/@types/astro').AstroStyleAttributes &
AstroDefineVarsAttribute;
// This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
diff --git a/packages/astro/env.d.ts b/packages/astro/env.d.ts
index 4b6ce7750318..a579d78ce27c 100644
--- a/packages/astro/env.d.ts
+++ b/packages/astro/env.d.ts
@@ -1,6 +1,6 @@
///
-type Astro = import('./dist/types/@types/astro').AstroGlobal;
+type Astro = import('./dist/@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)
/**
@@ -13,7 +13,7 @@ declare const Astro: Readonly;
declare const Fragment: any;
declare module '*.md' {
- type MD = import('./dist/types/@types/astro').MarkdownInstance>;
+ type MD = import('./dist/@types/astro').MarkdownInstance>;
export const frontmatter: MD['frontmatter'];
export const file: MD['file'];
@@ -30,7 +30,7 @@ declare module '*.md' {
}
declare module '*.mdx' {
- type MDX = import('astro').MDXInstance>;
+ type MDX = import('./dist/@types/astro').MDXInstance>;
export const frontmatter: MDX['frontmatter'];
export const file: MDX['file'];
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 711b8edf013a..d674ef69e5ed 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -12,19 +12,22 @@
},
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://astro.build",
- "types": "./dist/types/@types/astro.d.ts",
+ "types": "./dist/@types/astro.d.ts",
"typesVersions": {
"*": {
"app": [
- "./dist/types/core/app/index"
+ "./dist/core/app/index"
],
"app/*": [
- "./dist/types/core/app/*"
+ "./dist/core/app/*"
]
}
},
"exports": {
- ".": "./astro.js",
+ ".": {
+ "types": "./dist/@types/astro.d.ts",
+ "default": "./astro.js"
+ },
"./env": "./env.d.ts",
"./client": "./client.d.ts",
"./client-base": "./client-base.d.ts",
diff --git a/packages/astro/tsconfig.json b/packages/astro/tsconfig.json
index 58e865c0c7a0..a51690d2a925 100644
--- a/packages/astro/tsconfig.json
+++ b/packages/astro/tsconfig.json
@@ -3,7 +3,7 @@
"include": ["src", "index.d.ts"],
"compilerOptions": {
"allowJs": true,
- "declarationDir": "./dist/types",
+ "declarationDir": "./dist",
"module": "ES2020",
"outDir": "./dist",
"target": "ES2020",