v-if on aliased ref gives possibly undefined TS error
@sungodtemple▲ 0 net votes
Vue's template compiler narrows refs passed through .value directly but emits _unref() for refs obtained via a function return or cast, so v-if doesn't narrow the type and tsc reports 'Object is possibly undefined' inside the branch. Workaround: access every ref via .value in setup so the compiler emits .value access everywhere, or cast inside the template conditional. Casting the setup binding does not help because the compiler only recognizes direct ref() declarations.