uni-helper / uni-typed

为 uni-app、uni-cloud 和 uni-ui 组件提供 TypeScript 类型支持
MIT License
37 stars 3 forks source link

Vue: Argument of type { class: string; } is not assignable to parameter of type #12

Closed 1940879828 closed 3 months ago

1940879828 commented 3 months ago

描述问题

view tag and text tag type mismatch occurred Snipaste_2024-08-14_10-08-52

复现

package.json: { "name": "uni-preset-vue", "version": "0.0.0", "scripts": { "dev:app": "uni -p app", "dev:app-android": "uni -p app-android", "dev:app-ios": "uni -p app-ios", "dev:app-harmony": "uni -p app-harmony", "dev:custom": "uni -p", "dev:h5": "uni", "dev:h5:ssr": "uni --ssr", "dev:mp-alipay": "uni -p mp-alipay", "dev:mp-baidu": "uni -p mp-baidu", "dev:mp-jd": "uni -p mp-jd", "dev:mp-kuaishou": "uni -p mp-kuaishou", "dev:mp-lark": "uni -p mp-lark", "dev:mp-qq": "uni -p mp-qq", "dev:mp-toutiao": "uni -p mp-toutiao", "dev:mp-weixin": "uni -p mp-weixin", "dev:mp-xhs": "uni -p mp-xhs", "dev:quickapp-webview": "uni -p quickapp-webview", "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", "dev:quickapp-webview-union": "uni -p quickapp-webview-union", "build:app": "uni build -p app", "build:app-android": "uni build -p app-android", "build:app-ios": "uni build -p app-ios", "build:app-harmony": "uni build -p app-harmony", "build:custom": "uni build -p", "build:h5": "uni build", "build:h5:ssr": "uni build --ssr", "build:mp-alipay": "uni build -p mp-alipay", "build:mp-baidu": "uni build -p mp-baidu", "build:mp-jd": "uni build -p mp-jd", "build:mp-kuaishou": "uni build -p mp-kuaishou", "build:mp-lark": "uni build -p mp-lark", "build:mp-qq": "uni build -p mp-qq", "build:mp-toutiao": "uni build -p mp-toutiao", "build:mp-weixin": "uni build -p mp-weixin", "build:mp-xhs": "uni build -p mp-xhs", "build:quickapp-webview": "uni build -p quickapp-webview", "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", "build:quickapp-webview-union": "uni build -p quickapp-webview-union", "type-check": "vue-tsc --noEmit" }, "dependencies": { "@dcloudio/uni-app": "3.0.0-4020420240722002", "@dcloudio/uni-app-harmony": "3.0.0-4020420240722002", "@dcloudio/uni-app-plus": "3.0.0-4020420240722002", "@dcloudio/uni-components": "3.0.0-4020420240722002", "@dcloudio/uni-h5": "3.0.0-4020420240722002", "@dcloudio/uni-mp-alipay": "3.0.0-4020420240722002", "@dcloudio/uni-mp-baidu": "3.0.0-4020420240722002", "@dcloudio/uni-mp-jd": "3.0.0-4020420240722002", "@dcloudio/uni-mp-kuaishou": "3.0.0-4020420240722002", "@dcloudio/uni-mp-lark": "3.0.0-4020420240722002", "@dcloudio/uni-mp-qq": "3.0.0-4020420240722002", "@dcloudio/uni-mp-toutiao": "3.0.0-4020420240722002", "@dcloudio/uni-mp-weixin": "3.0.0-4020420240722002", "@dcloudio/uni-mp-xhs": "3.0.0-4020420240722002", "@dcloudio/uni-quickapp-webview": "3.0.0-4020420240722002", "bwip-js": "^4.5.0", "default-passive-events": "^2.0.0", "vue": "^3.4.21", "vue-i18n": "^9.1.9" }, "devDependencies": { "@dcloudio/types": "^3.3.2", "@dcloudio/uni-automator": "3.0.0-4020420240722002", "@dcloudio/uni-cli-shared": "3.0.0-4020420240722002", "@dcloudio/uni-stacktracey": "3.0.0-4020420240722002", "@dcloudio/vite-plugin-uni": "3.0.0-4020420240722002", "@uni-helper/uni-app-types": "^1.0.0-alpha.3", "@uni-helper/uni-ui-types": "^1.0.0-alpha.3", "@vue/runtime-core": "^3.4.21", "@vue/tsconfig": "^0.1.3", "sass": "^1.77.8", "typescript": "^5.5.2", "vite": "5.2.8", "vue-tsc": "^2.0.22" } } tsconfig.json: { "extends": "@vue/tsconfig/tsconfig.json", "compilerOptions": { "verbatimModuleSyntax": true, "ignoreDeprecations": "5.0", "sourceMap": true, "baseUrl": ".", "paths": { "@/": ["./src/"] }, "lib": ["esnext", "dom"], "types": ["@dcloudio/types", "@uni-helper/uni-app-types", "@uni-helper/uni-ui-types"] }, "vueCompilerOptions": { "plugins": ["@uni-helper/uni-app-types/volar-plugin"] }, "include": ["src//*.ts", "src/*/.d.ts", "src//*.tsx", "src/*/.vue"] }

The project use Vue3 Typescript Vite template https://gitee.com/dcloud/uni-preset-vue/repository/archive/vite-ts.zip

系统信息

windows11

使用的包管理器

npm

核对

ModyQyW commented 3 months ago

我本地使用 node 20.12.1、npm 10.5.0、VSC 1.92.2、Volar 2.0.28 和你提供的 package.json 和 tsconfig.json 无法复现,修复了 tsconfig.json 里面的错误也无法复现,如需要解决问题请具体提供你的开发环境和工具配置,也请你认真看一下 issue template 里面的提示。WebStorm 请先升级到最新版本再尝试复现。

SuperTylerX commented 3 months ago

出现同样问题已解决。是WebStorm集成的 @vue/language-server 版本问题,2024.1默认集成1.8.27,2024.2 默认集成2.0.26,升级到WebStorm 2024.2及以上版本或者手动指定安装最新的@vue/language-server可解决。

1940879828 commented 3 months ago

出现同样问题已解决。是WebStorm集成的 @vue/language-server 版本问题,2024.1默认集成1.8.27,2024.2 默认集成2.0.26,升级到WebStorm 2024.2及以上版本或者手动指定安装最新的@vue/language-server可解决。

有用的解决方案!可以说一下思路是怎么排查到是vue/language-server问题的吗

SuperTylerX commented 3 months ago

出现同样问题已解决。是WebStorm集成的 @vue/language-server 版本问题,2024.1默认集成1.8.27,2024.2 默认集成2.0.26,升级到WebStorm 2024.2及以上版本或者手动指定安装最新的@vue/language-server可解决。

有用的解决方案!可以说一下思路是怎么排查到是vue/language-server问题的吗

volar(@vue/language-server)类型错误问题在之前仓库issue里已做讨论:https://github.com/uni-helper/uni-app-types/issues/67

ModyQyW commented 3 months ago
image

也可以简单地认为 volar 约等于 @vue/language-server🤔

SeasideLee commented 1 month ago

出现同样问题已解决。是WebStorm集成的 @vue/language-server 版本问题,2024.1默认集成1.8.27,2024.2 默认集成2.0.26,升级到WebStorm 2024.2及以上版本或者手动指定安装最新的@vue/language-server可解决。

目前 webstorm 2024.2 的版本中 @vue/language-server 2.0.26 版本会出现 bug https://youtrack.jetbrains.com/issue/WEB-68756

如果要用的话还是升级到 2024.3 的先行版才可以