Vue 3 type guard checking if ref value is not null/undefined
npm install vue-is-defined
A Vue 3 composition API type guard utility that checks if a ref's value is defined (not null or undefined), with proper TypeScript type narrowing for safe property access.
``bash`
npm install vue-is-defined
`ts
import { isDefined } from 'vue-is-defined'
import { ref, computed } from 'vue'
const value = ref
const defined = isDefined(value)
console.log(defined.value) // true
value.value = undefined
console.log(defined.value) // false
``
MIT
Extracted from VueUse for standalone use.