发现两个升级依赖到3070020230201002后出现的异常,vue文件内的ts代码都变得奇怪起来了。一开始以为是别的依赖出现的问题,把其他依赖也升级到最新,但是还是异常。最后其他依赖保持最新,将 dcloudio 相关依赖换成旧版本后就正常了。
异常一:
d.ts 内定义
interface NewUni extends Uni { xxx: any }
declare const uni:NewUni
vue 单文件中调用 uni.xxx ,编辑器显示 uni 的类型为 Uni,uni.xxx 不存在。而ts文件中调用 uni.xxx,编辑器显示 uni 的类型为 NewUni,uni.xxx 为 any 类型,符合预期。
异常二:
<script lang="ts" setup>
import TestComponent from './testComponent.vue';
function testTap() {
// dosomething
}
</script>
<template>
<view @tap="testTap">
点击
</view>
<test-component />
</template>
这时候编辑器会提示
'testTap' is defined but never used.eslint@typescript-eslint/no-unused-vars
'TestComponent' is defined but never used.eslint@typescript-eslint/no-unused-vars
"dependencies": {
"@dcloudio/uni-app": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-app-plus": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-components": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-h5": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-alipay": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-baidu": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-lark": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-qq": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-mp-weixin": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3070020230201002",
"dingtalk-design-libs": "^0.0.24",
"moment": "^2.29.1",
"regenerator-runtime": "^0.12.1",
"umtrack-wx": "^2.7.1",
"vue": "3.2.45",
"vue-i18n": "9.2.2",
"vuex": "^4.1.0",
"vuex-persistedstate": "^4.0.0-beta.3"
},
"devDependencies": {
"@dcloudio/types": "^3.0.15",
"@dcloudio/uni-automator": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3070020230201002",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-3070020230201002",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3070020230201002",
"@types/node": "^18.0.0",
"@types/umtrack-wx": "^2.3.1",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.33.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^9.9.0",
"fs-lint": "^1.0.1",
"husky": "^6.0.0",
"jest": "27.0.4",
"mini-types": "^0.1.7",
"miniprogram-api-typings": "^3.9.0",
"prettier-eslint-cli": "^6.0.1",
"sass": "^1.49.10",
"typescript": "^4.9.4",
"vite": "^4.0.4",
"vue-tsc": "^1.0.24"
},
1 个回复
DCloud_UNI_WZF
cli 创建的 vue3 ts 项目吗,提供下测试工程