Discussed in #5030
Originally posted by TheDutchCoder December 7, 2024
We use TS to define props this way:
const props = defineProps<{
foo?: boolean
}>()
This all works, but Vue compiles optional booleans as false, not as undefined.
What's interesting is that in the template this works if you access props.foo, but not foo:
<template>
<!-- Throws error as foo can be undefined -->
<SomeComponent :is-visible="foo" />
</template>
<template>
<!-- This works as expected -->
<SomeComponent :is-visible="props.foo" />
</template>
Our question is: is this a Vue bug, or a language tools bug?