diff --git a/.changeset/healthy-poems-know.md b/.changeset/healthy-poems-know.md
new file mode 100644
index 000000000..a2448f71e
--- /dev/null
+++ b/.changeset/healthy-poems-know.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Replaces vite/client types with astro/client
diff --git a/examples/basics/tsconfig.json b/examples/basics/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/basics/tsconfig.json
+++ b/examples/basics/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/blog-multiple-authors/tsconfig.json b/examples/blog-multiple-authors/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/blog-multiple-authors/tsconfig.json
+++ b/examples/blog-multiple-authors/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/blog/tsconfig.json b/examples/blog/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/blog/tsconfig.json
+++ b/examples/blog/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/docs/tsconfig.json b/examples/docs/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/docs/tsconfig.json
+++ b/examples/docs/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/env-vars/src/env.d.ts b/examples/env-vars/src/env.d.ts
index 1cc8ccabc..35cb37076 100644
--- a/examples/env-vars/src/env.d.ts
+++ b/examples/env-vars/src/env.d.ts
@@ -1,4 +1,4 @@
-///
+///
interface ImportMetaEnv {
readonly DB_PASSWORD: string;
diff --git a/examples/env-vars/tsconfig.json b/examples/env-vars/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/env-vars/tsconfig.json
+++ b/examples/env-vars/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-alpine/tsconfig.json b/examples/framework-alpine/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/framework-alpine/tsconfig.json
+++ b/examples/framework-alpine/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-lit/tsconfig.json b/examples/framework-lit/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/framework-lit/tsconfig.json
+++ b/examples/framework-lit/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-multiple/tsconfig.json b/examples/framework-multiple/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/framework-multiple/tsconfig.json
+++ b/examples/framework-multiple/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-preact/tsconfig.json b/examples/framework-preact/tsconfig.json
index 8c4c4bb42..be8e3ea96 100644
--- a/examples/framework-preact/tsconfig.json
+++ b/examples/framework-preact/tsconfig.json
@@ -12,7 +12,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-react/tsconfig.json b/examples/framework-react/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/framework-react/tsconfig.json
+++ b/examples/framework-react/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-solid/tsconfig.json b/examples/framework-solid/tsconfig.json
index 3aae33ef4..45d5b5d48 100644
--- a/examples/framework-solid/tsconfig.json
+++ b/examples/framework-solid/tsconfig.json
@@ -12,7 +12,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-svelte/tsconfig.json b/examples/framework-svelte/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/framework-svelte/tsconfig.json
+++ b/examples/framework-svelte/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/framework-vue/tsconfig.json b/examples/framework-vue/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/framework-vue/tsconfig.json
+++ b/examples/framework-vue/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/integrations-playground/tsconfig.json b/examples/integrations-playground/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/integrations-playground/tsconfig.json
+++ b/examples/integrations-playground/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/minimal/tsconfig.json b/examples/minimal/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/minimal/tsconfig.json
+++ b/examples/minimal/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/non-html-pages/tsconfig.json b/examples/non-html-pages/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/non-html-pages/tsconfig.json
+++ b/examples/non-html-pages/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/portfolio/tsconfig.json b/examples/portfolio/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/portfolio/tsconfig.json
+++ b/examples/portfolio/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/ssr/tsconfig.json b/examples/ssr/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/ssr/tsconfig.json
+++ b/examples/ssr/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/starter/tsconfig.json b/examples/starter/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/starter/tsconfig.json
+++ b/examples/starter/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/subpath/tsconfig.json b/examples/subpath/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/subpath/tsconfig.json
+++ b/examples/subpath/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-markdown-plugins/tsconfig.json b/examples/with-markdown-plugins/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-markdown-plugins/tsconfig.json
+++ b/examples/with-markdown-plugins/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-markdown-shiki/tsconfig.json b/examples/with-markdown-shiki/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-markdown-shiki/tsconfig.json
+++ b/examples/with-markdown-shiki/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-markdown/tsconfig.json b/examples/with-markdown/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-markdown/tsconfig.json
+++ b/examples/with-markdown/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-mdx/tsconfig.json b/examples/with-mdx/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-mdx/tsconfig.json
+++ b/examples/with-mdx/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-nanostores/tsconfig.json b/examples/with-nanostores/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-nanostores/tsconfig.json
+++ b/examples/with-nanostores/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-tailwindcss/tsconfig.json b/examples/with-tailwindcss/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-tailwindcss/tsconfig.json
+++ b/examples/with-tailwindcss/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/examples/with-vite-plugin-pwa/tsconfig.json b/examples/with-vite-plugin-pwa/tsconfig.json
index 7ac81809a..4db6ee701 100644
--- a/examples/with-vite-plugin-pwa/tsconfig.json
+++ b/examples/with-vite-plugin-pwa/tsconfig.json
@@ -9,7 +9,7 @@
"resolveJsonModule": true,
// Enable stricter transpilation for better output.
"isolatedModules": true,
- // Add type definitions for our Vite runtime.
- "types": ["vite/client"]
+ // Add type definitions for our Astro runtime.
+ "types": ["astro/client"]
}
}
diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts
new file mode 100644
index 000000000..4c721c475
--- /dev/null
+++ b/packages/astro/client.d.ts
@@ -0,0 +1,207 @@
+///
+
+// CSS modules
+type CSSModuleClasses = { readonly [key: string]: string }
+
+declare module '*.module.css' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+declare module '*.module.scss' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+declare module '*.module.sass' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+declare module '*.module.less' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+declare module '*.module.styl' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+declare module '*.module.stylus' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+declare module '*.module.pcss' {
+ const classes: CSSModuleClasses
+ export default classes
+}
+
+// CSS
+declare module '*.css' {
+ const css: string
+ export default css
+}
+declare module '*.scss' {
+ const css: string
+ export default css
+}
+declare module '*.sass' {
+ const css: string
+ export default css
+}
+declare module '*.less' {
+ const css: string
+ export default css
+}
+declare module '*.styl' {
+ const css: string
+ export default css
+}
+declare module '*.stylus' {
+ const css: string
+ export default css
+}
+declare module '*.pcss' {
+ const css: string
+ export default css
+}
+
+// Built-in asset types
+// see `src/constants.ts`
+
+// images
+declare module '*.jpg' {
+ const src: string
+ export default src
+}
+declare module '*.jpeg' {
+ const src: string
+ export default src
+}
+declare module '*.png' {
+ const src: string
+ export default src
+}
+declare module '*.gif' {
+ const src: string
+ export default src
+}
+declare module '*.svg' {
+ const src: string
+ export default src
+}
+declare module '*.ico' {
+ const src: string
+ export default src
+}
+declare module '*.webp' {
+ const src: string
+ export default src
+}
+declare module '*.avif' {
+ const src: string
+ export default src
+}
+
+// media
+declare module '*.mp4' {
+ const src: string
+ export default src
+}
+declare module '*.webm' {
+ const src: string
+ export default src
+}
+declare module '*.ogg' {
+ const src: string
+ export default src
+}
+declare module '*.mp3' {
+ const src: string
+ export default src
+}
+declare module '*.wav' {
+ const src: string
+ export default src
+}
+declare module '*.flac' {
+ const src: string
+ export default src
+}
+declare module '*.aac' {
+ const src: string
+ export default src
+}
+
+// fonts
+declare module '*.woff' {
+ const src: string
+ export default src
+}
+declare module '*.woff2' {
+ const src: string
+ export default src
+}
+declare module '*.eot' {
+ const src: string
+ export default src
+}
+declare module '*.ttf' {
+ const src: string
+ export default src
+}
+declare module '*.otf' {
+ const src: string
+ export default src
+}
+
+// other
+declare module '*.wasm' {
+ const initWasm: (options: WebAssembly.Imports) => Promise
+ export default initWasm
+}
+declare module '*.webmanifest' {
+ const src: string
+ export default src
+}
+declare module '*.pdf' {
+ const src: string
+ export default src
+}
+declare module '*.txt' {
+ const src: string
+ export default src
+}
+
+// web worker
+declare module '*?worker' {
+ const workerConstructor: {
+ new (): Worker
+ }
+ export default workerConstructor
+}
+
+declare module '*?worker&inline' {
+ const workerConstructor: {
+ new (): Worker
+ }
+ export default workerConstructor
+}
+
+declare module '*?sharedworker' {
+ const sharedWorkerConstructor: {
+ new (): SharedWorker
+ }
+ export default sharedWorkerConstructor
+}
+
+declare module '*?raw' {
+ const src: string
+ export default src
+}
+
+declare module '*?url' {
+ const src: string
+ export default src
+}
+
+declare module '*?inline' {
+ const src: string
+ export default src
+}
diff --git a/packages/astro/env.d.ts b/packages/astro/env.d.ts
index 4f40def88..aa649c896 100644
--- a/packages/astro/env.d.ts
+++ b/packages/astro/env.d.ts
@@ -1,4 +1,4 @@
-///
+///
type Astro = import('astro').AstroGlobal;
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 9e20038cf..3a75922f9 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -26,6 +26,7 @@
"exports": {
".": "./astro.js",
"./env": "./env.d.ts",
+ "./client": "./client.d.ts",
"./astro-jsx": "./astro-jsx.d.ts",
"./jsx/*": "./dist/jsx/*",
"./jsx-runtime": "./dist/jsx-runtime/index.js",
@@ -63,6 +64,7 @@
"config.d.ts",
"config.mjs",
"env.d.ts",
+ "client.d.ts",
"astro-jsx.d.ts",
"README.md",
"vendor"
diff --git a/packages/astro/src/runtime/client/hmr.ts b/packages/astro/src/runtime/client/hmr.ts
index bc4780b01..98cf839af 100644
--- a/packages/astro/src/runtime/client/hmr.ts
+++ b/packages/astro/src/runtime/client/hmr.ts
@@ -1,3 +1,4 @@
+///
if (import.meta.hot) {
import.meta.hot.accept((mod) => mod);
diff --git a/packages/astro/tsconfig.json b/packages/astro/tsconfig.json
index c6b6bb7d1..58e865c0c 100644
--- a/packages/astro/tsconfig.json
+++ b/packages/astro/tsconfig.json
@@ -7,6 +7,6 @@
"module": "ES2020",
"outDir": "./dist",
"target": "ES2020",
- "types": ["vite/client"]
+ "types": ["./client"]
}
}