1.0.7 • Published 12 months ago

@lazycatcloud/wujie-typings v1.0.7

Weekly downloads
-
License
MulanPSL2
Repository
-
Last release
12 months ago

无界类型定义

fork by https://gitee.com/jh_shot/wujie-typings

基于 Wujie 1.0.6 版本编写

  • Vue组件
    • vue <= 2.6 引用 v26.d.ts
    • vue 2.7 引用 v27.d.ts
    • vue >= 3 引用 v3.d.ts
  • JSX组件引用 jsx.d.ts
  • 全局变量引用 global.d.ts

tsconfig.json 示例:

{
  "compilerOptions": {
    "types": [
      "@lazycatcloud/wujie-typings/global",
      "@lazycatcloud/wujie-typings/jsx"
    ]
  }
}

自定义 bus 类型

tsconfig.json 中添加 bus_overwrite

{
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "compilerOptions": {
    "types": [
      "vite-plugin-svg-icons/client",
      // ==================添加这两行
      "@lazycatcloud/wujie-typings/global",
      "@lazycatcloud/wujie-typings/bus_overwrite",
      // ==================
    ]
  },
}

然后自己覆盖掉 window.$wujie.bus

import { EventBus } from '@lazycatcloud/wujie-typings/bus_overwrite'

// 参考: https://github.com/developit/mitt
type RealBus = {
  'header:show'?: boolean
  'header:hide'?: boolean
}

declare global {
  interface Window {
    $wujie: {
      bus: EventBus<RealBus>
    }
  }
}

export {}
1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago