Vetur is underlining null on this line below:
const firstRef = ref<HTMLElement>(null)
No overload matches this call. Overload 1 of 3, '(raw: HTMLElement): Ref', gave the following error. Argument of type 'null' is not assignable to parameter of type 'HTMLElement'. Overload 2 of 3, '(raw: HTMLElement): Ref', gave the following error. Argument of type 'null' is not assignable to parameter of type 'HTMLElement'.Vetur(2769)
Here's a condensed context. Any ideas what I did wrong?
<template>
<input id="first" ref="firstRef">
<button type="button" @click.prevent="focusFirst">Focus</button>
</template>
<script lang="ts">
import { defineComponent, ref } from "@vue/composition-api"
export default defineComponent({
name: "Test",
setup() {
const firstRef = ref<HTMLElement>(null)
const focusFirst = () => {
const theField = firstRef.value
theField.focus()
}
return { focusFirst }
}
</script>