N
Nuxt2y ago
toni

How to access types of auto-imported components?

Currently I'm doing this to type template refs according to: https://vuejs.org/guide/typescript/composition-api.html#typing-component-template-refs Like so:
import AppDropdown from '~/components/app/dropdown/Dropdown.vue'
import EntryDetail from '~/components/entry/Detail.vue'

const dropdown = $ref<InstanceType<typeof AppDropdown> | null>(null)
const entryDetail = $ref<InstanceType<typeof EntryDetail> | null>(null)
import AppDropdown from '~/components/app/dropdown/Dropdown.vue'
import EntryDetail from '~/components/entry/Detail.vue'

const dropdown = $ref<InstanceType<typeof AppDropdown> | null>(null)
const entryDetail = $ref<InstanceType<typeof EntryDetail> | null>(null)
Is there a way to access the types of the auto-imported comps without explicitly importing them? Something like:
const dropdown = $ref<InstanceType<typeof #imports.AppDropdown> | null>(null)
const dropdown = $ref<InstanceType<typeof #imports.AppDropdown> | null>(null)
TypeScript with Composition API | Vue.js
Vue.js - The Progressive JavaScript Framework
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server