I’m working on a Vue SPA using the Quasar framework with TypeScript. My project structure has two folders - one for the Express backend and one for the Quasar frontend.
The issue I’m encountering is that VSCode keeps importing Node.js type definitions in my frontend code. This leads to problems because browser APIs like SetInterval
are supposed to return a number, but instead, they return NodeJS.Timeout
, which is intended for server-side code.
I believe this occurs because Quasar dependencies are automatically pulling in @types/node
. Here’s my current configuration:
{
"name": "my-spa-app",
"version": "1.0.0",
"description": "Vue SPA application",
"productName": "My App",
"author": "Developer",
"private": true,
"scripts": {
"serve": "quasar dev",
"compile": "quasar build",
"check": "eslint --ext .js,.ts,.vue ./src"
},
"dependencies": {
"@quasar/extras": "^1.16.4",
"axios": "^1.2.1",
"quasar": "^2.6.0",
"vue": "^3.0.0",
"vue-router": "^4.0.0",
"pinia": "^2.0.11"
},
"devDependencies": {
"@quasar/app-vite": "^1.3.0",
"typescript": "^4.5.4",
"eslint": "^8.10.0"
}
}
I tried fixing this by adding package overrides:
"overrides": {
"@types/node": "0.0.0"
}
This eliminates the primary Node types, but some nested dependencies still have their own copies. What’s the best way to ensure my frontend only uses browser-compatible types?