Skip to content

defineComponent "components" intellisense doesn't work #5434

@gzimbron

Description

@gzimbron

Vue - Official extension or vue-tsc version

2.2.10

VSCode version

1.101.0 (Universal)

Vue version

3.5.13

TypeScript version

~5.8.0

System Info

System:
    OS: macOS 15.5
    CPU: (14) arm64 Apple M4 Pro
    Memory: 197.56 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.11.0 - ~/.local/state/fnm_multishells/99632_1750267088077/bin/node
    npm: 10.9.0 - ~/.local/state/fnm_multishells/99632_1750267088077/bin/npm
    pnpm: 10.12.1 - ~/Library/pnpm/pnpm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Browsers:
    Chrome: 137.0.7151.104
    Safari: 18.5

package.json dependencies

{ 
  "dependencies": {
    "pinia": "^3.0.1",
    "vue": "^3.5.13",
    "vue-router": "^4.5.0"
  },
  "devDependencies": {
    "@tsconfig/node22": "^22.0.1",
    "@types/node": "^22.14.0",
    "@vitejs/plugin-vue": "^5.2.3",
    "@vue/eslint-config-prettier": "^10.2.0",
    "@vue/eslint-config-typescript": "^14.5.0",
    "@vue/tsconfig": "^0.7.0",
    "eslint": "^9.22.0",
    "eslint-plugin-vue": "~10.0.0",
    "jiti": "^2.4.2",
    "npm-run-all2": "^7.0.2",
    "prettier": "3.5.3",
    "typescript": "~5.8.0",
    "vite": "^6.2.4",
    "vite-plugin-vue-devtools": "^7.7.2",
    "vue-tsc": "^2.2.8"
  }
}

Steps to reproduce

I have a TestView.vue, TestView.ts and TestComponent.vue files for this scenario

TestComponent.vue

<script setup lang="ts">
defineProps<{
  msg: string
}>()
</script>

<template>
  <p>Message:</p>
  <div>{{ msg }}</div>
</template>

TestView.vue

<script lang="ts" src="./TestView.ts"></script>

<template>
  <p>{{ something }}</p>

  <TestComponent></TestComponent>
</template>

TestVue.ts

import TestComponent from '@/components/TestComponent.vue'
import { defineComponent, ref } from 'vue'

export default defineComponent({
  components: {
    TestComponent,
  },
  setup() {
    const something = ref('hello world')

    return {
      something,
    }
  },
})

TestComponent works fine in TestView.vue SFC, but, intellisense doesn't work at all:

Image

Adding "TestComponent" to return setup function in TestView.ts fix this,

Image

Image

Is it correct to use the export of components inside the return of the setup function? Or how can I solve this issue when returning components in the components property of defineComponent?"

What is expected?

Image

What is actually happening?

Intellisense doesn't work with components from defineComponent function

Link to minimal reproduction

No response

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions