Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript always report an error #327

Closed
earthaYan opened this issue Aug 10, 2023 · 3 comments
Closed

typescript always report an error #327

earthaYan opened this issue Aug 10, 2023 · 3 comments

Comments

@earthaYan
Copy link

I create a vue3 project as docs said,with TypeScript and vue-router,but everytime I create a new *.vue file under views foler and add it to routes which defined in src/router/index.ts,the vscode alaways report an error in src/router/index.ts and disappeared after restarting vscode

File 'd:/private/frontend/resume-generator/src/views/TestView.vue' is not listed within the file list of project 'd:/private/frontend/resume-generator/tsconfig.vitest.json'. Projects must list all files or use an 'include' pattern.ts(6307)

here are my files

//tsconfig.json
{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.node.json"
    },
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.vitest.json"
    }
  ]
}
//tsconfig.node.json
{
  "extends": "@tsconfig/node18/tsconfig.json",
  "include": [
    "vite.config.*",
    "vitest.config.*",
    "cypress.config.*",
    "nightwatch.conf.*",
    "playwright.config.*"
  ],
  "compilerOptions": {
    "composite": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "types": ["node"]
  }
}
//tsconfig.app.json
{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "composite": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    },
    "isolatedModules": true
  }
}
//tsconfig.vitest.json
{
  "extends": "./tsconfig.app.json",
  "exclude": [],
  "compilerOptions": {
    "composite": true,
    "lib": [],
    "types": ["node", "jsdom"]
  }
}

//router/index.ts
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import RegisterLoginView from '../views/RegisterLoginView.vue'

export const routes: RouteRecordRaw[] = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/sign',
    name: 'sign',
    component: RegisterLoginView
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/AboutView.vue')
  },
  {
    path: '/test',
    name: 'test',
    component: () => import('../views/TestView.vue')
  }
]
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router

@earthaYan
Copy link
Author

I found one solution to this :open the takeover mode

@sodatea
Copy link
Member

sodatea commented Aug 19, 2023

It could be a bug in either VS Code or https://github.com/vuejs/language-tools.
Or, according to the error log, could be a path casing issue (d:\ vs D:\).

Considering takeover mode works as expected, I think the setup in this scaffold is fine. So I'm closing this issue.

@sodatea sodatea closed this as completed Aug 19, 2023
@sodatea
Copy link
Member

sodatea commented Aug 19, 2023

Maybe related: vuejs/language-tools#2271 Please make sure your Volar extension version is up-to-date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants