Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor Vite's importMeta.d.ts inside our repo to workaround issue with tsc on Linux #4499

Merged
merged 4 commits into from Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .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
2 changes: 1 addition & 1 deletion packages/astro/client-base.d.ts
@@ -1,4 +1,4 @@
/// <reference types="vite/types/importMeta" />
/// <reference path="./import-meta.d.ts" />
bluwy marked this conversation as resolved.
Show resolved Hide resolved

// CSS modules
type CSSModuleClasses = { readonly [key: string]: string };
Expand Down
37 changes: 37 additions & 0 deletions 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
// <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>

/* 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;
}
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.