update
Some checks failed
deploy / deploy (push) Has been cancelled

This commit is contained in:
toom1996
2026-08-19 01:27:36 +08:00
parent d14dd7e2db
commit e1552feb8c
5 changed files with 20 additions and 33 deletions

14
src/env.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
// 全局类型声明补充
// @astrojs/alpinejs 集成会在运行时把 Alpine 挂到全局(window.Alpine),
// 但 @types/alpinejs 是 CJS(export = Alpine),其顶层 declare const Alpine
// 不会自动进入模块上下文(.astro 的 <script> 是模块),导致 IDE 报 “Cannot find name 'Alpine'”。
// 这里用 namespace 导入取真实的 Alpine.Alpine 接口类型作为全局声明,
// 既消除报错、又让 Alpine.data / .store / .magic 等方法以及 data 组件内的 this 都有完整提示。
// 注意:@types/alpinejs 是 export = 形式,不能用默认导入(会解析成 namespace 而非类型)。
import type * as Alpine from "alpinejs";
declare global {
const Alpine: Alpine.Alpine;
}
export {};