vuejs / language-tools

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

Vue Compiler Option "skipTemplateCodegen = false" for components with slots broke JetBrains IDE tips #4606

Open karpov-dev opened 3 months ago

karpov-dev commented 3 months ago

Vue - Official extension or vue-tsc version

2.0.28 and older versions

VSCode version

-

Vue version

3.4.21 - doesn't matter

TypeScript version

5.4.2 - doesn't matter

System Info

System:
    OS: macOS 15.0
    CPU: (8) arm64 Apple M1
    Memory: 94.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.5.1 - /usr/local/bin/node
    npm: 10.5.0 - /opt/homebrew/bin/npm
  Browsers:
    Safari: 18.0

Steps to reproduce

vite.config

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "node:path";

export default defineConfig({
  plugins: [vue()],

  build: {
    lib: {
      entry: resolve(__dirname, "src/index.ts"),
      formats: ['es'],
      name: "ui-kit",
      fileName: "ui-kit",
    },
    rollupOptions: {
      external: ["vue"],
      output: {
        globals: {
          vue: "Vue",
        },
      },
    },
  },
})

package.json

{
  "name": "some-lib",
  "private": false,
  "version": "3.19.1",
  "files": [
    "dist"
  ],
  "main": "./dist/ui-kit.mjs",
  "module": "./dist/ui-kit.mjs",
  "exports": {
    ".": {
      "import": "./dist/ui-kit.mjs"
    },
    "./styles": "./dist/style.css"
  },
  "browser": {
    ".": "./dist/ui-kit.es.js"
  },
  "types": "./dist/index.d.ts",
  "scripts": {
    "ui-kit:run": "vite",
    "ui-kit:build": "vite build && vue-tsc --emitDeclarationOnly",
    "prepublishOnly": "npm run ui-kit:build"
  },
  "dependencies": {
    "@vueuse/core": "^10.9.0",
    "camelcase": "^8.0.0",
    "clone": "^2.1.2",
    "delay": "^6.0.0",
    "fast-sort": "^3.4.0",
    "highlight-words": "^1.2.2",
    "html-to-image": "^1.11.11",
    "html2canvas": "^1.4.1",
    "vue": "^3.4.21"
  },
  "devDependencies": {
    "@types/clone": "^2.1.1",
    "@types/node": "^20.11.27",
    "@vitejs/plugin-vue": "^5.0.4",
    "@vue/cli-service": "^5.0.8",
    "mongodb": "^6.5.0",
    "sass": "^1.71.1",
    "tsc-alias": "^1.8.8",
    "typescript": "^5.4.2",
    "vite": "5.1.6",
    "vue-router": "^4.3.0",
    "vue-tsc": "^2.0.28",
    "vue3-toastify": "^0.2.1"
  }
}

tsconfig

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "module": "ESNext",
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    // "noEmit": true,
    "jsx": "preserve",

    "outDir": "dist",
    "declaration": true,

    /* Linting */
    "strict": true,
    "noUnusedLocals": false,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitAny": false
  },
  "exclude": ["src/App.vue", "src/main.ts"],
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/components/*.vue"],
  "references": [{ "path": "./tsconfig.node.json" }],
}

What is expected?

JetBrains IDE shows tips + auto-import works

1 3

What is actually happening?

Tips was not showed

2

Link to minimal reproduction

No response

Any additional comments?

Workaround - set "skipTemplateCodegen" to "true" in tsconfig.json to avoid if in line https://github.com/vuejs/language-tools/blob/fed447dcb61325ceb590227e8cb3738cd0e6aaaf/packages/language-core/lib/codegen/script/scriptSetup.ts#L248 which generated __VLS_template for slots. In VSCode all cases works correctly. I had changed several versions on JetBrains IDE - it's not connected with IDE version + not connected with node version

Thanks!

Workaround: set in tsconfig.json "vueCompilerOptions": { "skipTemplateCodegen": true }