antfu-collective / vitesse-webext

⚡️ WebExtension Vite Starter Template
MIT License
2.92k stars 225 forks source link

升级依赖后,事件相关会报ts错误 #92

Closed dxhuii closed 2 years ago

dxhuii commented 2 years ago

Describe the bug

@keydown="(e: KeyboardEvent) => {
                if (e.key === 'Enter') {
                  so()
                }
              }"

不能将类型“(e: KeyboardEvent) => void”分配给类型“KeyboardEvent”。ts(2322) __VLS_types.ts(107, 56): 所需类型来自属性 "keydown",在此处的 "EventObject<undefined, "keydown", {}, KeyboardEvent | undefined>" 类型上声明该属性

@click="so()"

不能将类型“($event: any) => void”分配给类型“MouseEvent”。ts(2322) __VLS_types.ts(107, 56): 所需类型来自属性 "click",在此处的 "EventObject<undefined, "click", {}, MouseEvent | undefined>" 类型上声明该属性

<Field v-slot="{ handleChange, value }" name="password">
          <input :value="value" name="password" type="password" class="mt-4 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 border rounded-md p-3" @input="handleChange">
        </Field>

不能将类型“(e: unknown, shouldValidate?: boolean | undefined) => void”分配给类型“Event”。ts(2322) __VLS_types.ts(107, 56): 所需类型来自属性 "input",在此处的 "EventObject<undefined, "input", {}, Event | undefined>" 类型上声明该属性

package.json

{
  "name": "vitesse-webext",
  "displayName": "Vitesse WebExt",
  "version": "0.0.1",
  "private": true,
  "packageManager": "pnpm@7.9.4",
  "description": "[description]",
  "scripts": {
    "dev": "npm run clear && cross-env NODE_ENV=development run-p dev:*",
    "dev:prepare": "esno scripts/prepare.ts",
    "dev:web": "vite",
    "dev:js": "npm run build:js -- --mode development",
    "build": "cross-env NODE_ENV=production run-s clear build:web build:prepare build:js",
    "build:prepare": "esno scripts/prepare.ts",
    "build:web": "vite build",
    "build:js": "vite build --config vite.config.content.ts",
    "pack": "cross-env NODE_ENV=production run-p pack:*",
    "pack:zip": "rimraf extension.zip && jszip-cli add extension/* -o ./extension.zip",
    "pack:crx": "crx pack extension -o ./extension.crx",
    "pack:xpi": "cross-env WEB_EXT_ARTIFACTS_DIR=./ web-ext build --source-dir ./extension --filename extension.xpi --overwrite-dest",
    "start:chromium": "web-ext run --source-dir ./extension --target=chromium",
    "start:firefox": "web-ext run --source-dir ./extension --target=firefox-desktop",
    "clear": "rimraf extension/dist extension/manifest.json extension.*",
    "lint": "eslint .",
    "test": "vitest test"
  },
  "dependencies": {
    "crypto-js": "^4.1.1",
    "element-plus": "^2.2.17",
    "ohmyfetch": "^0.4.19",
    "vee-validate": "^4.6.10",
    "vuedraggable": "^4.1.0",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@antfu/eslint-config": "^0.27.0",
    "@ffflorian/jszip-cli": "^3.1.6",
    "@iconify/json": "^2.1.119",
    "@types/chrome": "^0.0.197",
    "@types/crypto-js": "^4.1.1",
    "@types/fs-extra": "^9.0.13",
    "@types/node": "^18.8.4",
    "@types/webextension-polyfill": "^0.9.1",
    "@typescript-eslint/eslint-plugin": "^5.40.0",
    "@unocss/reset": "^0.45.29",
    "@vitejs/plugin-vue": "^3.1.2",
    "@vue/compiler-sfc": "^3.2.40",
    "@vue/test-utils": "^2.1.0",
    "@vueuse/core": "^9.3.0",
    "chokidar": "^3.5.3",
    "cross-env": "^7.0.3",
    "crx": "^5.0.1",
    "eslint": "^8.25.0",
    "esno": "^0.16.3",
    "fs-extra": "^10.1.0",
    "jsdom": "^20.0.1",
    "kolorist": "^1.6.0",
    "npm-run-all": "^4.1.5",
    "rimraf": "^3.0.2",
    "typescript": "^4.8.4",
    "unocss": "^0.45.29",
    "unplugin-auto-import": "^0.11.2",
    "unplugin-icons": "^0.14.11",
    "unplugin-vue-components": "^0.22.8",
    "vite": "^3.1.7",
    "vitest": "^0.24.1",
    "vue": "^3.2.40",
    "vue-demi": "^0.13.11",
    "web-ext": "^7.2.0",
    "webext-bridge": "^5.0.5",
    "webextension-polyfill": "^0.10.0"
  }
}

Reproduction

System Info

vscode: 版本: 1.72.0
vscode插件
TypeScript Vue Plugin (Volar):v1.0.3
Vue Language Features (Volar):v1.0.3

System:
    OS: macOS 12.5.1
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 198.71 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 106.0.5249.103
    Safari: 15.6.1

Used Package Manager

pnpm

Validations

dxhuii commented 2 years ago

https://github.com/vuejs/core/pull/6855 https://blog.csdn.net/m_uncle/article/details/127285662