Skip to content

templateRef NPM Version

Stability: official

Automatically infer type for templateRef (from VueUse) and useTemplateRef (Vue 3.5+).

WARNING

This feature is officially supported since Volar (vue-tsc) v2.1.0. You can remove this plugin and use the built-in support in Volar.

FeaturesSupported
Volar

Basic Usage

vue
<script setup lang="ts">
import { 
templateRef
} from '@vueuse/core'
import {
Comp
} from './Comp.ts'
const
comp
=
templateRef
('comp')
comp
.
value
?.
foo
</script> <template> <
Comp
ref
="
comp
" />
</template>
ts
import { defineComponent } from 'vue'

export const Comp = defineComponent({
  setup() {
    return { foo: 1 }
  },
})

Volar Configuration

No configuration required.

Contributors

Changelog