You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add foo.vue file with a code below. This is almost same as the example in Vue official docs.
<script setup lang="ts">
import { useTemplateRef, onMounted } from'vue';// the first argument must match the ref value in the templateconst input =useTemplateRef('my-input');onMounted(() => {input.value?.focus();});
</script>
<template>
<inputref="my-input" />
</template>
What is expected?
Running vue-tsc shouldn't raise an error, input.value should be inferred as HTMLInputElement | null (same as actual runtime behavior).
What is actually happening?
Raises an error below.
src/App.vue:8:16 - error TS2551: Property 'focus' does not exist on type 'InputHTMLAttributes & ReservedProps'. Did you mean 'onFocus'?
8 input.value?.focus();
~~~~~
Vue - Official extension or vue-tsc version
2.1.4
VSCode version
null
Vue version
3.5.0
TypeScript version
5.5.4
System Info
package.json dependencies
Steps to reproduce
Add
foo.vue
file with a code below. This is almost same as the example in Vue official docs.What is expected?
Running
vue-tsc
shouldn't raise an error,input.value
should be inferred asHTMLInputElement | null
(same as actual runtime behavior).What is actually happening?
Raises an error below.
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-mmua2t?file=src%2FApp.vue
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: