Skip to content

vue-tsc v2.2.8 cases type error after emitting declaration files #5232

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

Closed
qmhc opened this issue Mar 3, 2025 · 5 comments · Fixed by #5239
Closed

vue-tsc v2.2.8 cases type error after emitting declaration files #5232

qmhc opened this issue Mar 3, 2025 · 5 comments · Fixed by #5239
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first 🔨 p3-minor-bug

Comments

@qmhc
Copy link
Contributor

qmhc commented Mar 3, 2025

Vue - Official extension or vue-tsc version

^2.2.8

VSCode version

none

Vue version

^3.5.13

TypeScript version

~5.7.3

System Info

System:
  OS: Linux 5.0 undefined
  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 18.20.3 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 10.2.3 - /usr/local/bin/npm
  pnpm: 8.15.6 - /usr/local/bin/pnpm

package.json dependencies

{
  "name": "dts-test",
  "version": "0.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "run-p type-check \"build-only {@}\" --",
    "preview": "vite preview",
    "build-only": "vite build",
    "type-check": "vue-tsc --build",
    "tsc": "vue-tsc --noEmit false --declaration --emitDeclarationOnly --declarationMap --outDir dist"
  },
  "dependencies": {
    "vue": "^3.5.13"
  },
  "devDependencies": {
    "@tsconfig/node22": "^22.0.0",
    "@types/node": "^22.13.4",
    "@vitejs/plugin-vue": "^5.2.1",
    "@vue/tsconfig": "^0.7.0",
    "npm-run-all2": "^7.0.2",
    "typescript": "~5.7.3",
    "vite": "^6.2.0",
    "vite-plugin-vue-devtools": "^7.7.2",
    "vue-tsc": "^2.2.8"
  }
}

Steps to reproduce

Run pnpm run tsc then check ./dist/App.vue.d.ts.

What is expected?

No type error in ./dist/App.vue.d.ts.

What is actually happening?

Many __VLS_Xxxx types case error.

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-oc7njgdm?file=package.json&view=editor

Any additional comments?

Might be this commit imported the issue.

@brc-dd
Copy link
Member

brc-dd commented Mar 3, 2025

Also, causing this - qmhc/vite-plugin-dts#416

If you do per-file compilation - vue-tsc --declaration --emitDeclarationOnly src/App.vue then it adds the declare global block. But even then these ts-ignore comments are stripped -

// @ts-ignore
function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
// @ts-ignore
- which will throw error if someone has skipLibCheck: false.

@KazariEX
Copy link
Member

KazariEX commented Mar 3, 2025

@brc-dd do you mean that we only need to solve the errors in these few lines? It seems that we forgot to add generic constraints.

@brc-dd
Copy link
Member

brc-dd commented Mar 3, 2025

No that's separate.

export function generateGlobalTypes({

These types are not being injected in dts in the stackblitz example the author shared above. They are injected if you run vue-tsc for single file. But if you run for whole project they are not injected.

@KazariEX
Copy link
Member

KazariEX commented Mar 3, 2025

Clear.

@KazariEX
Copy link
Member

KazariEX commented Mar 3, 2025

@brc-dd Can you open a new issue for your situation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first 🔨 p3-minor-bug
Projects
None yet
3 participants