提交 81060627 作者: 方治民

chore: 修改 uni.d.ts 描述文件

上级 353f399c
import fs from 'node:fs'
import type { Plugin } from 'vite'
import fs from 'fs'
import prettier from 'prettier'
// uni-app
......@@ -11,12 +11,17 @@ import tags from '@dcloudio/uni-helper-json/dist/tags.json'
* 根据 @dcloudio/uni-helper-json 生成组件 .d.ts 描述文件,对组件进行高亮展示
*/
function generateUniComponentsTypes() {
const components = Object.keys(tags).map((key) => `'${key}': typeof HTMLElement`)
const components = Object.keys(tags).map((key) => `'${key}': UniComponent`)
const content = `
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// uni-app 内置组件高亮
// shime-uni.d.ts
type Hooks = App.AppInstance & Page.PageInstance;
interface ComponentCustomOptions extends Hooks {}
// uni-app components
interface UniComponent extends HTMLElement {}
export interface GlobalComponents {
${components.join(',\n\t')}
}
......@@ -28,7 +33,7 @@ function generateUniComponentsTypes() {
parser: 'typescript',
...require('../../prettier.config'),
})
fs.writeFileSync('./types/uni-components.d.ts', formatted, 'utf8')
fs.writeFileSync('./types/uni.d.ts', formatted, 'utf8')
}
/**
......
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// uni-app 内置组件高亮
export interface GlobalComponents {
block: typeof HTMLElement
view: typeof HTMLElement
'scroll-view': typeof HTMLElement
'match-media': typeof HTMLElement
swiper: typeof HTMLElement
'swiper-item': typeof HTMLElement
'movable-view': typeof HTMLElement
'movable-area': typeof HTMLElement
text: typeof HTMLElement
'rich-text': typeof HTMLElement
progress: typeof HTMLElement
button: typeof HTMLElement
'checkbox-group': typeof HTMLElement
checkbox: typeof HTMLElement
form: typeof HTMLElement
input: typeof HTMLElement
label: typeof HTMLElement
picker: typeof HTMLElement
'picker-view': typeof HTMLElement
'radio-group': typeof HTMLElement
radio: typeof HTMLElement
slider: typeof HTMLElement
switch: typeof HTMLElement
textarea: typeof HTMLElement
navigator: typeof HTMLElement
audio: typeof HTMLElement
image: typeof HTMLElement
video: typeof HTMLElement
map: typeof HTMLElement
canvas: typeof HTMLElement
'web-view': typeof HTMLElement
'cover-view': typeof HTMLElement
'cover-image': typeof HTMLElement
icon: typeof HTMLElement
'picker-view-column': typeof HTMLElement
camera: typeof HTMLElement
'live-player': typeof HTMLElement
'live-pusher': typeof HTMLElement
'open-data': typeof HTMLElement
ad: typeof HTMLElement
'ad-draw': typeof HTMLElement
'navigation-bar': typeof HTMLElement
'custom-tab-bar': typeof HTMLElement
'page-meta': typeof HTMLElement
editor: typeof HTMLElement
'unicloud-db': typeof HTMLElement
}
}
export {}
// generated by @dcloudio/uni-helper-json/dist/tags.json
declare module 'vue' {
// shime-uni.d.ts
type Hooks = App.AppInstance & Page.PageInstance
interface ComponentCustomOptions extends Hooks {}
// uni-app components
interface UniComponent extends HTMLElement {}
export interface GlobalComponents {
block: UniComponent
view: UniComponent
'scroll-view': UniComponent
'match-media': UniComponent
swiper: UniComponent
'swiper-item': UniComponent
'movable-view': UniComponent
'movable-area': UniComponent
text: UniComponent
'rich-text': UniComponent
progress: UniComponent
button: UniComponent
'checkbox-group': UniComponent
checkbox: UniComponent
form: UniComponent
input: UniComponent
label: UniComponent
picker: UniComponent
'picker-view': UniComponent
'radio-group': UniComponent
radio: UniComponent
slider: UniComponent
switch: UniComponent
textarea: UniComponent
navigator: UniComponent
audio: UniComponent
image: UniComponent
video: UniComponent
map: UniComponent
canvas: UniComponent
'web-view': UniComponent
'cover-view': UniComponent
'cover-image': UniComponent
icon: UniComponent
'picker-view-column': UniComponent
camera: UniComponent
'live-player': UniComponent
'live-pusher': UniComponent
'open-data': UniComponent
ad: UniComponent
'ad-draw': UniComponent
'navigation-bar': UniComponent
'custom-tab-bar': UniComponent
'page-meta': UniComponent
editor: UniComponent
'unicloud-db': UniComponent
}
}
export {}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论