Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

VS Code builtin tsserver/TypeScript support picks tsconfig.vitest.json instead of tsconfig.app.json for ts files #159

Closed
@segevfiner

Description

@segevfiner

Follow up to talking to myself in#151 😛

Create a new create-vue project with everything but tsx selected. In this configuration, VS Code's builtin tsserver/TypeScript support seems to picktsconfig.vitest.json, instead oftsconfig.app.json. It seems the logic to pick them is different between Volar and tsserver, as changing their order intsconfig.json causes Volar to be the one to selecttsconfig.vitest.json instead oftsconfig.app.json.

Adding the following totsconfig.vitest.json:

"references": [    {"path":"./tsconfig.app.json" }  ]

Seems to make VS Code selecttsconfig.app.json for ts files properly, but this is some pure guess work and I'm not sure where or how the logic to select an appropriate tsconfig works.

In addition:

  1. We are usingvue-tsc --noEmit -p tsconfig.vitest.json --composite false to type check, but in case the user wants to add additional projects to the project references config, this won't type check them. Apparently--build,composite, and project references don't supportnoEmit, so we need to useemitDeclarationOnly,declarationDir instead to make it emit types to some folder solely for the purpose of type checking. On the plus side, in this mode it reuses them when it can for faster type checking (It also enablesincremental).
  2. tsconfig.vitest.json has"lib": [], but this should probably be"lib": ["ES2016"] to matchtsconfig.app.json just without DOM.

So basically the following changes to the generated project seems to fix those things for me:

diff --git a/.gitignore b/.gitignoreindex 38adffa..b2e683b 100644--- a/.gitignore+++ b/.gitignore@@ -13,6 +13,8 @@ dist dist-ssr coverage *.local+types+*.tsbuildinfo  /cypress/videos/ /cypress/screenshots/diff --git a/package.json b/package.jsonindex 4c8c275..1a7cbc7 100644--- a/package.json+++ b/package.json@@ -9,7 +9,7 @@     "test:e2e": "start-server-and-test preview http://localhost:4173/ 'cypress open --e2e'",     "test:e2e:ci": "start-server-and-test preview http://localhost:4173/ 'cypress run --e2e'",     "build-only": "vite build",-    "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",+    "type-check": "vue-tsc --build",     "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"   },   "dependencies": {diff --git a/tsconfig.app.json b/tsconfig.app.jsonindex cdbea1d..0e1bcdc 100644--- a/tsconfig.app.json+++ b/tsconfig.app.json@@ -3,6 +3,8 @@   "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],   "exclude": ["src/**/__tests__/*"],   "compilerOptions": {+    "emitDeclarationOnly": true,+    "declarationDir": "types",     "composite": true,     "baseUrl": ".",     "paths": {diff --git a/tsconfig.config.json b/tsconfig.config.jsonindex c2d3a30..8577b3c 100644--- a/tsconfig.config.json+++ b/tsconfig.config.json@@ -2,6 +2,8 @@   "extends": "@vue/tsconfig/tsconfig.node.json",   "include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],   "compilerOptions": {+    "emitDeclarationOnly": true,+    "declarationDir": "types",     "composite": true,     "types": ["node"]   }diff --git a/tsconfig.vitest.json b/tsconfig.vitest.jsonindex d080d61..d0d8b87 100644--- a/tsconfig.vitest.json+++ b/tsconfig.vitest.json@@ -2,8 +2,13 @@   "extends": "./tsconfig.app.json",   "exclude": [],   "compilerOptions": {+    "emitDeclarationOnly": true,+    "declarationDir": "types",     "composite": true,-    "lib": [],+    "lib": ["ES2016"],     "types": ["node", "jsdom"]-  }+  },+  "references": [+    { "path": "./tsconfig.app.json" }+  ] }

@sodatea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp