瀏覽代碼

feat(types): 添加 uni-app 类型声明支持- 新增 shime-uni.d.ts 文件,导出空对象并扩展 vue 模块类型
- 新增 shims-uni.d.ts 文件,引入 @dcloudio/types 并扩展 @vue/runtime-core 模块类型- 为 vue 组件选项添加 App 和 Page 实例的类型合并支持- 提供 uni-app 项目中的 TypeScript 类型推断支持

nahida 7 月之前
父節點
當前提交
253befc4c3
共有 2 個文件被更改,包括 16 次插入0 次删除
  1. 10 0
      shims-uni.d.ts
  2. 6 0
      src/shime-uni.d.ts

+ 10 - 0
shims-uni.d.ts

@@ -0,0 +1,10 @@
+/// <reference types='@dcloudio/types' />
+import 'vue'
+
+declare module '@vue/runtime-core' {
+  type Hooks = App.AppInstance & Page.PageInstance;
+
+  interface ComponentCustomOptions extends Hooks {
+
+  }
+}

+ 6 - 0
src/shime-uni.d.ts

@@ -0,0 +1,6 @@
+export {}
+
+declare module "vue" {
+  type Hooks = App.AppInstance & Page.PageInstance;
+  interface ComponentCustomOptions extends Hooks {}
+}