uni-helper / unocss-preset-uni

专为 uni-app 打造的 UnoCSS 预设
MIT License
74 stars 6 forks source link

unocss升级0.59以后,本插件就报错了 Type 'Preset<object>' is not assignable to type 'PresetOrFactory<object> | PresetOrFactory<object>[]'. #13

Closed jocstech closed 7 months ago

jocstech commented 8 months ago

描述问题

Type 'Preset' is not assignable to type 'PresetOrFactory | PresetOrFactory[]'. Type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.58.5/node_modules/@unocss/core/dist/index").Preset' is not assignable to type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.59.0/node_modules/@unocss/core/dist/index").Preset'. Types of property 'rules' are incompatible. Type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.58.5/node_modules/@unocss/core/dist/index").Rule[] | undefined' is not assignable to type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.59.0/node_modules/@unocss/core/dist/index").Rule[] | undefined'. Type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.58.5/node_modules/@unocss/core/dist/index").Rule[]' is not assignable to type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.59.0/node_modules/@unocss/core/dist/index").Rule[]'. Type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.58.5/node_modules/@unocss/core/dist/index").Rule' is not assignable to type 'import("/Users/jocs/Projects/hna/uniapph5/node_modules/.pnpm/@unocss+core@0.59.0/node_modules/@unocss/core/dist/index").Rule'. Type '[RegExp, DynamicMatcher]' is not assignable to type 'Rule'. Type '[RegExp, DynamicMatcher]' is not assignable to type '[string, CSSObject | CSSEntries] | [RegExp, DynamicMatcher]'. Type '[RegExp, DynamicMatcher]' is not assignable to type '[string, CSSObject | CSSEntries]'. Type at position 0 in source is not compatible with type at position 0 in target. Type 'RegExp' is not assignable to type 'string'.ts(2322)

复现

"dependencies": { "@climblee/uv-ui": "^1.1.20", "@dcloudio/uni-app": "3.0.0-3090920231225001", "@dcloudio/uni-app-plus": "3.0.0-3090920231225001", "@dcloudio/uni-components": "3.0.0-3090920231225001", "@dcloudio/uni-h5": "3.0.0-3090920231225001", "@dcloudio/uni-mp-alipay": "3.0.0-3090920231225001", "@dcloudio/uni-mp-baidu": "3.0.0-3090920231225001", "@dcloudio/uni-mp-jd": "3.0.0-3090920231225001", "@dcloudio/uni-mp-kuaishou": "3.0.0-3090920231225001", "@dcloudio/uni-mp-lark": "3.0.0-3090920231225001", "@dcloudio/uni-mp-qq": "3.0.0-3090920231225001", "@dcloudio/uni-mp-toutiao": "3.0.0-3090920231225001", "@dcloudio/uni-mp-weixin": "3.0.0-3090920231225001", "@dcloudio/uni-mp-xhs": "3.0.0-3090920231225001", "@dcloudio/uni-quickapp-webview": "3.0.0-3090920231225001", "@dcloudio/uni-ui": "^1.5.5", "@vueuse/core": "^10.9.0", "colors.ts": "^1.0.20", "crypto-js": "^4.2.0", "date-fns": "^3.6.0", "gio-miniprogram-sdk-cdp": "^3.8.19", "gio-webjs-sdk-cdp": "^3.8.6", "pinia": "2.0.36", "pinia-auto-refs": "^0.0.10", "radash": "^12.1.0", "vconsole": "^3.15.1", "vue": "^3.4.21", "vue-i18n": "^9.11.0" }, "devDependencies": { "@antfu/eslint-config": "^2.12.2", "@dcloudio/types": "^3.4.8", "@dcloudio/uni-automator": "3.0.0-3090920231225001", "@dcloudio/uni-cli-shared": "3.0.0-3090920231225001", "@dcloudio/uni-stacktracey": "3.0.0-3090920231225001", "@dcloudio/vite-plugin-uni": "3.0.0-3090920231225001", "@iconify-json/carbon": "^1.1.31", "@types/node": "^20.12.5", "@uni-helper/eslint-config": "^0.0.6", "@uni-helper/uni-app-types": "^0.5.12", "@uni-helper/uni-env": "^0.1.1", "@uni-helper/uni-ui-types": "^0.5.13", "@uni-helper/unocss-preset-uni": "^0.2.7", "@uni-helper/vite-plugin-uni-components": "^0.0.9", "@uni-helper/vite-plugin-uni-layouts": "^0.1.7", "@uni-helper/vite-plugin-uni-manifest": "^0.2.3", "@uni-helper/vite-plugin-uni-pages": "^0.2.15", "@uni-helper/volar-service-uni-pages": "^0.2.15", "@unocss/eslint-config": "^0.59.0", "@unocss/eslint-plugin": "^0.59.0", "@vue/runtime-core": "^3.4.21", "@vue/tsconfig": "^0.5.1", "chalk": "^5.3.0", "compressing": "^1.10.0", "eslint": "^9.0.0", "eslint-plugin-format": "^0.1.0", "fs-extra": "^11.2.0", "husky": "^9.0.11", "lint-staged": "^15.2.2", "sass": "^1.74.1", "sass-loader": "^14.1.1", "simple-git-hooks": "^2.11.1", "typescript": "^5.4.4", "unocss": "^0.59.0", "unplugin-auto-import": "^0.17.5", "vite": "5.2.8", "vite-plugin-vconsole": "^2.1.1", "vue-tsc": "^2.0.11" },

系统信息

System:
    OS: macOS 13.2.1
    CPU: (8) arm64 Apple M2
    Memory: 53.55 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - ~/Library/pnpm/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 8.15.4 - ~/Library/pnpm/pnpm
    bun: 1.0.2 - ~/.bun/bin/bun
  Browsers:
    Chrome: 123.0.6312.87
    Edge: 123.0.2420.81
    Safari: 16.3

使用的包管理器

pnpm

核对

  • [X] 遵循我们的 行为准则
  • [X] 检查是否已经有一个报告相同错误的问题,以避免重复创建。
  • [X] 这是一个具体的错误。请开启 GitHub 讨论你的疑问。
  • [X] 所提供的复现是这个问题的 最小复现
ModyQyW commented 7 months ago

方便确认一下 0.58.5 是哪个依赖安装的吗?

huchaomin commented 7 months ago

我也遇到了相同的情况,但是unocss 降级到0.58.9就没有问题

ModyQyW commented 7 months ago

如果忽略ts类型问题,可以正常运行吗?如果可以,就不用管什么东西,如果不行,就先降级到 0.58.9 吧

ModyQyW commented 7 months ago

在 unocss-preset-uni v0.2.8 尝试解决这个问题,这涉及到 unocss v0.59 和 unocss-applet v0.8,请看一下 README 来调整一下依赖,如果7天左右没回应我就会关闭这个issue了 @jocstech @huchaomin

huchaomin commented 7 months ago

可以,非常感谢 @ModyQyW