From 1f42c0791c342740d3650dc04a15c3610f9ab00a Mon Sep 17 00:00:00 2001
From: Erika <3019731+Princesseuh@users.noreply.github.com>
Date: Fri, 26 Aug 2022 12:47:39 -0300
Subject: [PATCH] Vendor Vite's importMeta.d.ts inside our repo to workaround
issue with `tsc` on Linux (#4499)
* Update @astrojs/language-server to latest version
* Vendor importMeta.d.ts from Vite inside our repo to workaround TypeScript issue on Linux
* Remove unnecessary change
* Add changeset
---
.changeset/hungry-adults-juggle.md | 5 ++++
packages/astro/client-base.d.ts | 2 +-
packages/astro/import-meta.d.ts | 37 ++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 .changeset/hungry-adults-juggle.md
create mode 100644 packages/astro/import-meta.d.ts
diff --git a/.changeset/hungry-adults-juggle.md b/.changeset/hungry-adults-juggle.md
new file mode 100644
index 000000000..c174d7158
--- /dev/null
+++ b/.changeset/hungry-adults-juggle.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix `tsc` not being able to find Vite's import.meta types on Linux
diff --git a/packages/astro/client-base.d.ts b/packages/astro/client-base.d.ts
index 1e65d7f71..1219e150c 100644
--- a/packages/astro/client-base.d.ts
+++ b/packages/astro/client-base.d.ts
@@ -1,4 +1,4 @@
-///
+///
// CSS modules
type CSSModuleClasses = { readonly [key: string]: string };
diff --git a/packages/astro/import-meta.d.ts b/packages/astro/import-meta.d.ts
new file mode 100644
index 000000000..2b05d0a65
--- /dev/null
+++ b/packages/astro/import-meta.d.ts
@@ -0,0 +1,37 @@
+// File vendored from Vite itself, as a workaround to https://github.com/vitejs/vite/pull/9827 until Vite 4 comes out
+
+// This file is an augmentation to the built-in ImportMeta interface
+// Thus cannot contain any top-level imports
+//
+
+/* eslint-disable @typescript-eslint/consistent-type-imports */
+
+// Duplicate of import('../src/node/importGlob').GlobOptions in order to
+// avoid breaking the production client type. Because this file is referenced
+// in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist.
+interface GlobOptions {
+ as?: string;
+}
+
+interface ImportMeta {
+ url: string;
+
+ readonly hot?: import('vite/types/hot').ViteHotContext;
+
+ readonly env: ImportMetaEnv;
+
+ glob: import('vite/types/importGlob').ImportGlobFunction;
+ /**
+ * @deprecated Use `import.meta.glob('*', { eager: true })` instead
+ */
+ globEager: import('vite/types/importGlob').ImportGlobEagerFunction;
+}
+
+interface ImportMetaEnv {
+ [key: string]: any;
+ BASE_URL: string;
+ MODE: string;
+ DEV: boolean;
+ PROD: boolean;
+ SSR: boolean;
+}