Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defineProps doesn't support methods syntax #2983

Closed
jods4 opened this issue Jan 10, 2021 · 0 comments
Closed

defineProps doesn't support methods syntax #2983

jods4 opened this issue Jan 10, 2021 · 0 comments

Comments

@jods4
Copy link
Contributor

jods4 commented Jan 10, 2021

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants