defineProps doesn't support methods syntax
Version
3.0.5
Steps to reproduce
Playing with TS script setup, I did this:
<template>
<a @click="ok">OK</a>
</template>
<script setup lang="ts">
import { defineProps } from "vue"
defineProps<{ ok: () => void }>()
</script>
And it works fine.
But now change to a method instead of a field (in practice the same thing, but more concise):
<script setup lang="ts">
import { defineProps } from "vue"
defineProps<{ ok(): void }>()
</script>
And now it doesn't work anymore.
What is expected?
Ideally: works the same with both syntaxes. If not: a warning that methods are not a supported way to type props.
What is actually happening?
Nothing happens: nothing is bound at runtime and no message is displayed during compilation.
My guess is that the ok()
method is totally ignored by the compiler, which probably only considers fields.
This then leads to the prop being non existent.