Skip to content

[Bug]: Using generics in defineProps breaks useTemplateRef return type #5840

@ayrtonandino

Description

@ayrtonandino

Vue - Official extension or vue-tsc version

3.1.8, 3.1.7, 3.1.6, (3.1.5 works)

VSCode version

1.106.3

Vue version

3.5.25

TypeScript version

5.9.3

System Info

System:
    OS: macOS 13.7.8
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 102.95 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Yarn: 4.12.0 - /usr/local/bin/yarn
    npm: 11.6.2 - /Users/ayrtonandinobonazzola/Library/Application Support/Herd/config/nvm/versions/node/v24.11.1/bin/npm
    pnpm: 10.17.1 - /usr/local/bin/pnpm
  Browsers:
    Edge: 143.0.3650.66
    Firefox Developer Edition: 146.0
    Safari: 18.6

package.json dependencies

"dependencies": {
    "vue": "3.5.25"
  },
  "devDependencies": {
    "@types/node": "^24.10.2",
    "@vitejs/plugin-vue": "^6.0.2",
    "unplugin-vue-components": "^30.0.0",
    "vite": "^7.2.7",
    "vue-tsc": "^3.1.8"
  }

Steps to reproduce

To start:

  • install dependencies
npm install
  • run vue-tsc
npm run test
  • observe error on line 12 in /src/components/Comp2.vue

  • Comment out line 5 (generic?: T)

  • run test again and observe error on line 12 disappears

What is expected?

to work

What is actually happening?

throws error TS2339 on src/components/Comp2.vue:12:20

Link to minimal reproduction

https://github.com/ayrtonandino/vue-tsc-bug-templateRef-generics

Any additional comments?

This bugs appears only on auto imported components, (from unplugin-vue-components), that use generics in defineProps, if manually imported it work fine.

Also this bug was not pressent in vue-tsc <= 3.1.5, only 3.1.6 onwards

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions