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
Volar already does a good job at narrowing types (from T | undefined to just T) inside of text interpolations ({{ ... }}) and attribute bindings (like :example="...") that are in some way wrapped in a v-if (or another "control flow directive"), but it doesn't seem to do any type narrowing for expressions inside of event handlers (like @example="...").
Here's a small component for reproducing the issue:
<scriptsetuplang="ts">import { ref } from'vue'const foo =ref<{ bar:'Hello' }>()</script>
<template>
<div>
<!-- `foo` properly narrowed inside of the curly braces -->
<divv-if="foo">
Test 1: {{ foo.bar }}
</div>
<!-- `foo` properly narrowed inside of `:title` -->
<divv-if="foo" :title="foo.bar">
Test 2
<!-- Also works here -->
<span :title="foo.bar">Test 2 nested</span>
</div>
<!-- `foo` still possibly `undefined` inside of `@click` -->
<divv-if="foo" @click="alert(foo.bar)">
Test 3
<!-- Same problem here -->
<span @click="alert(foo.bar)">Test 3 nested</span>
</div>
</div>
</template>
Apart from tiny issues like this Volar works really well for me by the way, keep up the great work! 🙌
The text was updated successfully, but these errors were encountered:
Volar already does a good job at narrowing types (from
T | undefined
to justT
) inside of text interpolations ({{ ... }}
) and attribute bindings (like:example="..."
) that are in some way wrapped in av-if
(or another "control flow directive"), but it doesn't seem to do any type narrowing for expressions inside of event handlers (like@example="..."
).Here's a small component for reproducing the issue:
Apart from tiny issues like this Volar works really well for me by the way, keep up the great work! 🙌
The text was updated successfully, but these errors were encountered: