feat(uni): 增加uni类型提示,修复uni不认识的报错

This commit is contained in:
Burt 2023-12-22 09:36:27 +08:00
parent cae7de9d17
commit 37a109a3c3
6 changed files with 113 additions and 3 deletions

View File

@ -72,4 +72,7 @@ module.exports = {
typescript: {}, typescript: {},
}, },
}, },
globals: {
uni: true,
},
} }

View File

@ -77,8 +77,10 @@
"@dcloudio/uni-cli-shared": "3.0.0-3081220230817001", "@dcloudio/uni-cli-shared": "3.0.0-3081220230817001",
"@dcloudio/uni-stacktracey": "3.0.0-3081220230817001", "@dcloudio/uni-stacktracey": "3.0.0-3081220230817001",
"@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001", "@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001",
"@types/wechat-miniprogram": "^3.4.7",
"@typescript-eslint/eslint-plugin": "^6.15.0", "@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0", "@typescript-eslint/parser": "^6.15.0",
"@uni-helper/uni-app-types": "^0.5.12",
"@vue/runtime-core": "^3.2.45", "@vue/runtime-core": "^3.2.45",
"@vue/tsconfig": "^0.1.3", "@vue/tsconfig": "^0.1.3",
"autoprefixer": "^10.4.16", "autoprefixer": "^10.4.16",

91
pnpm-lock.yaml generated
View File

@ -76,12 +76,18 @@ devDependencies:
'@dcloudio/vite-plugin-uni': '@dcloudio/vite-plugin-uni':
specifier: 3.0.0-3081220230817001 specifier: 3.0.0-3081220230817001
version: 3.0.0-3081220230817001(postcss@8.4.32)(vite@4.1.4)(vue@3.2.47) version: 3.0.0-3081220230817001(postcss@8.4.32)(vite@4.1.4)(vue@3.2.47)
'@types/wechat-miniprogram':
specifier: ^3.4.7
version: 3.4.7
'@typescript-eslint/eslint-plugin': '@typescript-eslint/eslint-plugin':
specifier: ^6.15.0 specifier: ^6.15.0
version: 6.15.0(@typescript-eslint/parser@6.15.0)(eslint@8.56.0)(typescript@4.9.5) version: 6.15.0(@typescript-eslint/parser@6.15.0)(eslint@8.56.0)(typescript@4.9.5)
'@typescript-eslint/parser': '@typescript-eslint/parser':
specifier: ^6.15.0 specifier: ^6.15.0
version: 6.15.0(eslint@8.56.0)(typescript@4.9.5) version: 6.15.0(eslint@8.56.0)(typescript@4.9.5)
'@uni-helper/uni-app-types':
specifier: ^0.5.12
version: 0.5.12(typescript@4.9.5)
'@vue/runtime-core': '@vue/runtime-core':
specifier: ^3.2.45 specifier: ^3.2.45
version: 3.3.13 version: 3.3.13
@ -3559,6 +3565,10 @@ packages:
'@types/node': 20.10.5 '@types/node': 20.10.5
dev: true dev: true
/@types/wechat-miniprogram@3.4.7:
resolution: {integrity: sha512-X6SVOOaTPQN24lYBSV5jLuWyIedx8DGJnT0VUBnoNzJruhxotCL28ecGb7AO5JfXOXtHqSS5+CnJ70NxFxmisA==}
dev: true
/@types/yargs-parser@21.0.3: /@types/yargs-parser@21.0.3:
resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==}
dev: true dev: true
@ -3704,6 +3714,17 @@ packages:
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
dev: true dev: true
/@uni-helper/uni-app-types@0.5.12(typescript@4.9.5):
resolution: {integrity: sha512-SeUEgDgGftI4XEp1AB3C6IFLnRPT83tgTCCmlLUBmQyHh+UhRY+CX4QtgQ0n/kF8txNUq8Bc9YwKlYdXQGx6Ww==}
engines: {node: '>=14.18'}
peerDependencies:
typescript: ^4.8.0 || ^5.0.0
dependencies:
'@dcloudio/types': 3.4.3
typescript: 4.9.5
vue3: /vue@3.3.13(typescript@4.9.5)
dev: true
/@unocss/astro@0.58.0(vite@4.1.4): /@unocss/astro@0.58.0(vite@4.1.4):
resolution: {integrity: sha512-df+tEFO5eKXjQOwSWQhS9IdjD0sfLHLtn8U09sEKR2Nmh5CvpwyBxmvLQgOCilPou7ehmyKfsyGRLZg7IMp+Ew==} resolution: {integrity: sha512-df+tEFO5eKXjQOwSWQhS9IdjD0sfLHLtn8U09sEKR2Nmh5CvpwyBxmvLQgOCilPou7ehmyKfsyGRLZg7IMp+Ew==}
peerDependencies: peerDependencies:
@ -4050,12 +4071,34 @@ packages:
postcss: 8.4.32 postcss: 8.4.32
source-map: 0.6.1 source-map: 0.6.1
/@vue/compiler-sfc@3.3.13:
resolution: {integrity: sha512-DQVmHEy/EKIgggvnGRLx21hSqnr1smUS9Aq8tfxiiot8UR0/pXKHN9k78/qQ7etyQTFj5em5nruODON7dBeumw==}
dependencies:
'@babel/parser': 7.23.6
'@vue/compiler-core': 3.3.13
'@vue/compiler-dom': 3.3.13
'@vue/compiler-ssr': 3.3.13
'@vue/reactivity-transform': 3.3.13
'@vue/shared': 3.3.13
estree-walker: 2.0.2
magic-string: 0.30.5
postcss: 8.4.32
source-map-js: 1.0.2
dev: true
/@vue/compiler-ssr@3.2.47: /@vue/compiler-ssr@3.2.47:
resolution: {integrity: sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==} resolution: {integrity: sha512-wVXC+gszhulcMD8wpxMsqSOpvDZ6xKXSVWkf50Guf/S+28hTAXPDYRTbLQ3EDkOP5Xz/+SY37YiwDquKbJOgZw==}
dependencies: dependencies:
'@vue/compiler-dom': 3.2.47 '@vue/compiler-dom': 3.2.47
'@vue/shared': 3.2.47 '@vue/shared': 3.2.47
/@vue/compiler-ssr@3.3.13:
resolution: {integrity: sha512-d/P3bCeUGmkJNS1QUZSAvoCIW4fkOKK3l2deE7zrp0ypJEy+En2AcypIkqvcFQOcw3F0zt2VfMvNsA9JmExTaw==}
dependencies:
'@vue/compiler-dom': 3.3.13
'@vue/shared': 3.3.13
dev: true
/@vue/devtools-api@6.5.1: /@vue/devtools-api@6.5.1:
resolution: {integrity: sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==} resolution: {integrity: sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==}
dev: false dev: false
@ -4089,6 +4132,16 @@ packages:
estree-walker: 2.0.2 estree-walker: 2.0.2
magic-string: 0.25.9 magic-string: 0.25.9
/@vue/reactivity-transform@3.3.13:
resolution: {integrity: sha512-oWnydGH0bBauhXvh5KXUy61xr9gKaMbtsMHk40IK9M4gMuKPJ342tKFarY0eQ6jef8906m35q37wwA8DMZOm5Q==}
dependencies:
'@babel/parser': 7.23.6
'@vue/compiler-core': 3.3.13
'@vue/shared': 3.3.13
estree-walker: 2.0.2
magic-string: 0.30.5
dev: true
/@vue/reactivity@3.2.47: /@vue/reactivity@3.2.47:
resolution: {integrity: sha512-7khqQ/75oyyg+N/e+iwV6lpy1f5wq759NdlS1fpAhFXa8VeAIKGgk2E/C4VF59lx5b+Ezs5fpp/5WsRYXQiKxQ==} resolution: {integrity: sha512-7khqQ/75oyyg+N/e+iwV6lpy1f5wq759NdlS1fpAhFXa8VeAIKGgk2E/C4VF59lx5b+Ezs5fpp/5WsRYXQiKxQ==}
dependencies: dependencies:
@ -4120,6 +4173,14 @@ packages:
'@vue/shared': 3.2.47 '@vue/shared': 3.2.47
csstype: 2.6.21 csstype: 2.6.21
/@vue/runtime-dom@3.3.13:
resolution: {integrity: sha512-JJkpE8R/hJKXqVTgUoODwS5wqKtOsmJPEqmp90PDVGygtJ4C0PtOkcEYXwhiVEmef6xeXcIlrT3Yo5aQ4qkHhQ==}
dependencies:
'@vue/runtime-core': 3.3.13
'@vue/shared': 3.3.13
csstype: 3.1.3
dev: true
/@vue/server-renderer@3.2.47(vue@3.2.47): /@vue/server-renderer@3.2.47(vue@3.2.47):
resolution: {integrity: sha512-dN9gc1i8EvmP9RCzvneONXsKfBRgqFeFZLurmHOveL7oH6HiFXJw5OGu294n1nHc/HMgTy6LulU/tv5/A7f/LA==} resolution: {integrity: sha512-dN9gc1i8EvmP9RCzvneONXsKfBRgqFeFZLurmHOveL7oH6HiFXJw5OGu294n1nHc/HMgTy6LulU/tv5/A7f/LA==}
peerDependencies: peerDependencies:
@ -4129,6 +4190,16 @@ packages:
'@vue/shared': 3.2.47 '@vue/shared': 3.2.47
vue: 3.2.47 vue: 3.2.47
/@vue/server-renderer@3.3.13(vue@3.3.13):
resolution: {integrity: sha512-vSnN+nuf6iSqTL3Qgx/9A+BT+0Zf/VJOgF5uMZrKjYPs38GMYyAU1coDyBNHauehXDaP+zl73VhwWv0vBRBHcg==}
peerDependencies:
vue: 3.3.13
dependencies:
'@vue/compiler-ssr': 3.3.13
'@vue/shared': 3.3.13
vue: 3.3.13(typescript@4.9.5)
dev: true
/@vue/shared@3.2.47: /@vue/shared@3.2.47:
resolution: {integrity: sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ==} resolution: {integrity: sha512-BHGyyGN3Q97EZx0taMQ+OLNuZcW3d37ZEVmEAyeoA9ERdGvm9Irc/0Fua8SNyOtV1w6BS4q25wbMzJujO9HIfQ==}
@ -5413,6 +5484,10 @@ packages:
/csstype@2.6.21: /csstype@2.6.21:
resolution: {integrity: sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==} resolution: {integrity: sha512-Z1PhmomIfypOpoMjRQB70jfvy/wxT50qW08YXO5lMIJkrdq4yOTR+AW7FqutScmB9NkLwxo+jU+kZLbofZZq/w==}
/csstype@3.1.3:
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
dev: true
/currently-unhandled@0.4.1: /currently-unhandled@0.4.1:
resolution: {integrity: sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==} resolution: {integrity: sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
@ -12490,6 +12565,22 @@ packages:
'@vue/server-renderer': 3.2.47(vue@3.2.47) '@vue/server-renderer': 3.2.47(vue@3.2.47)
'@vue/shared': 3.2.47 '@vue/shared': 3.2.47
/vue@3.3.13(typescript@4.9.5):
resolution: {integrity: sha512-LDnUpQvDgsfc0u/YgtAgTMXJlJQqjkxW1PVcOnJA5cshPleULDjHi7U45pl2VJYazSSvLH8UKcid/kzH8I0a0Q==}
peerDependencies:
typescript: '*'
peerDependenciesMeta:
typescript:
optional: true
dependencies:
'@vue/compiler-dom': 3.3.13
'@vue/compiler-sfc': 3.3.13
'@vue/runtime-dom': 3.3.13
'@vue/server-renderer': 3.3.13(vue@3.3.13)
'@vue/shared': 3.3.13
typescript: 4.9.5
dev: true
/w3c-hr-time@1.0.2: /w3c-hr-time@1.0.2:
resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==}
deprecated: Use your platform's native performance.now() and performance.timeOrigin. deprecated: Use your platform's native performance.now() and performance.timeOrigin.

4
src/components.d.ts vendored
View File

@ -7,7 +7,7 @@ export {}
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
RouterLink: (typeof import('vue-router'))['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: (typeof import('vue-router'))['RouterView'] RouterView: typeof import('vue-router')['RouterView']
} }
} }

View File

@ -11,6 +11,17 @@
import { ref } from 'vue' import { ref } from 'vue'
import { fun, fun as yy } from '../../test/import-sort' import { fun, fun as yy } from '../../test/import-sort'
uni.showModal({
title: '提示',
content: '这是一个模态弹窗',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
},
})
const title = ref('Hello') const title = ref('Hello')
fun() fun()
yy() yy()

View File

@ -6,7 +6,10 @@
"@/*": ["./src/*"] "@/*": ["./src/*"]
}, },
"lib": ["esnext", "dom"], "lib": ["esnext", "dom"],
"types": ["@dcloudio/types"] "types": ["@dcloudio/types", "@types/wechat-miniprogram", "@uni-helper/uni-app-types"]
},
"vueCompilerOptions": {
"nativeTags": ["block", "template", "component", "slot"]
}, },
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]