vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.82k stars 396 forks source link

Throwing ERROR(vue-tsc) from an external library #3458

Closed AlanLes closed 3 months ago

AlanLes commented 1 year ago

Hello, after updating vue-tsc to 1.8.8 in one of the projects, I'm having problems with it throwing an error from an external library. When the project runs with vite, the vue-tsc throws an error from the external open-source component-library. This library is based on a different vue-tsc version, but I think it shouldn't be an issue (it's an external library after all), should it? I think the skipLibCheck flag in the tsconfig.json should do the job, but for some reason it doesn't.

The tsconfig in the project is the following:

{
  "compilerOptions": {
    "outDir": "./dist",
    "allowJs": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "noImplicitAny": true,
    "jsx": "preserve",
    "lib": [
      "esnext",
      "dom",
      "dom.Iterable"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "verbatimModuleSyntax": true,
    "importHelpers": true,
    "experimentalDecorators": true,
    "baseUrl": "./",
    "paths": {
      "@/*": [
        "src/*"
      ],
      "@customization/*": [
        "customization/*"
      ]
    },
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "ESNext",
    "types": [
      "vitest/globals",
      "vite/client"
    ],
    "useDefineForClassFields": true
  },
  "include": [
    "src/**/*",
    "tests/**/*",
    "e2e/**/*",
    "stories/**/*",
    "scripts/**/*",
    "customization/**/*",
    "**/*.ts.vue",
    ".eslintrc.js",
    "vite.config.ts",
    "playwright.config.ts",
    "vite-plugins/*.ts"
  ]
}
becbaile-te commented 1 year ago

I am seeing this too. skipLibCheck is true and node_modules is in the excludes array, but I am still seeing errors related to node_modules.

> npx vue-tsc --project tsconfig.gen-dts.json --noEmit

node_modules/vue-slider-component/lib/utils/control.ts:554:22 - error TS6133: 'pos' is declared but its value is never read.

554     dotsPos.forEach((pos, i) => {
                         ~~~

Found 1 error in node_modules/vue-slider-component/lib/utils/control.ts:554
prof-schnitzel commented 1 year ago

This has nothing to do with vue-tsc, because this is a typescript limitation. If you import ts files from node_modules, it will be checked by typescript, no matter if skipLibCheck is set to true or not. You have to import transpiled javascript files, not ts files.

See the typescript issue: https://github.com/microsoft/TypeScript/issues/40426

AlanLes commented 1 year ago

Yeeep, but I have those for the .vue files (which are obviously not .ts files), so what in this case?

so1ve commented 1 year ago

I'm not sure if we can avoid this behavior: https://github.com/vuejs/language-tools/blob/master/packages/vue-tsc/bin/vue-tsc.js#L15-L17

Volar needs to patch tsc to include .vue files so they can get typechecked, which leads to this error

desprit commented 9 months ago

I have no direct imports from the node_modules but still have that same issue in turbo monorepo.

davidmatter commented 3 months ago

Please check if this issue has been resolved in version 2.x. If not, feel free to create a new one.