This commit is contained in:
toom1996
2026-09-14 21:30:15 +08:00
parent 548155625d
commit afff2d9a49
52 changed files with 2997 additions and 2753 deletions

6
src/env.d.ts vendored
View File

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