Files
frontend_v2/src/env.d.ts
toom1996 afff2d9a49 update
2026-09-14 21:30:15 +08:00

15 lines
781 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 全局类型声明补充
// @astrojs/alpinejs 集成会在运行时把 Alpine 挂到全局(window.Alpine),
// 但 @types/alpinejs 是 CJS(export = Alpine),其顶层 declare const Alpine
// 不会自动进入模块上下文(.astro 的 <script> 是模块),导致 IDE 报 “Cannot find name 'Alpine'”。
// 用默认类型导入 `import type Alpine from "alpinejs"` 取真实的 Alpine.Alpine 接口类型作为全局声明,
// 既消除报错、又让 Alpine.data / .store / .magic 等方法以及 data 组件内的 this 都有完整提示。
// @types/alpinejs 是 export = 形式,esModuleInterop 开启时允许默认导入,TS 亦建议此种写法。
import type Alpine from "alpinejs";
declare global {
const Alpine: Alpine.Alpine;
}
export {};