最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - Quasar CLI importing @typesnode on SPA browser frontend setup causing SetInterval and other conflicts - Stack Overf

programmeradmin0浏览0评论

I have what I believe is a fairly boilerplate install of Quasar CLI (which uses Vite) frontend setup which is meant to be an SPA. I have one folder for my backend which is express + node.js and the other is a frontend folder with the Quasar CLi installed. Both use typescript.

The issue is, in VSCode when working on the frontend workspace folder, the IDE is pulling node_modules/@types/node types which means SetInterval and others return NodeJS.Timeout instead of a number. It's a number on the browser, a Timeout object within Node.

I'm wondering the best way to resolve this or if my config is somehow wrong. I'm not referencing @types/node myself, its a dependency from quasar I believe. But here's my package.json anyway:

package.json:

{
  "name": "frontend",
  "version": "0.1.0",
  "description": "na",
  "productName": "na",
  "author": "NA",
  "private": true,
  "scripts": {
    "_lint": "eslint --ext .js,.ts,.vue ./",
    "lint": "echo LINT DISABLED",
    "test": "echo \"No test specified\" && exit 0",
    "dev": "quasar dev",
    "build": "quasar build"
  },
  "dependencies": {
    "@quasar/extras": "^1.16.4",
    "axios": "^1.2.1",
    "chart.js": "^4.4.7",
    "chartjs-adapter-date-fns": "^3.0.0",
    "date-fns": "^4.1.0",
    "pinia": "^2.0.11",
    "quasar": "^2.6.0",
    "vue": "^3.0.0",
    "vue-chartjs": "^5.3.2",
    "vue-router": "^4.0.0"
  },
  "devDependencies": {
    "@quasar/app-vite": "^1.3.0",
    "@typescript-eslint/eslint-plugin": "^5.10.0",
    "@typescript-eslint/parser": "^5.10.0",
    "autoprefixer": "^10.4.2",
    "eslint": "^8.10.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-plugin-import": "^2.20.1",
    "eslint-plugin-vue": "^9.0.0",
    "typescript": "^4.5.4"
  },
  "engines": {
    "node": "^22 || ^18 || ^16",
    "npm": ">= 8.0.0",
    "yarn": ">= 1.21.1"
  },
}

I've tried setting

"overrides": {
    "@types/node": "0.0.0"
  }

which fixes the root level @types/node from being installed but other modules seem to have their own local copies which causes the issue still.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论