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 is not compiled in a nested scope in SFC script setup #4469

Closed
juzerzarif opened this issue Aug 29, 2021 · 2 comments
Closed

defineProps is not compiled in a nested scope in SFC script setup #4469

juzerzarif opened this issue Aug 29, 2021 · 2 comments

Comments

@juzerzarif
Copy link

Version

3.2.6

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Call defineProps in a script setup SFC file in a scope that is not at the top level.

What is expected?

defineProps should be compiled to __props

What is actually happening?

defineProps is called at runtime causing a ReferenceError


Implementation like the repo example is useful when defining a component with generic props

@edison1105 edison1105 added the 🐞 bug Something isn't working label Aug 30, 2021
@posva
Copy link
Member

posva commented Aug 30, 2021

defineEmits() is a macro, it needs to be able to statically analyze what is passed to it in order to know what to generate, so it doesn't seem reasonable to be used that way as it doesn't get called in reality, even less with a generic T that is never given any type.

Maybe you are looking for this: #3682

@posva posva closed this as completed Aug 30, 2021
@edison1105 edison1105 removed the 🐞 bug Something isn't working label Aug 30, 2021
@juzerzarif
Copy link
Author

@posva That PR does seem like it would be a possible solution for what I'm looking for. But since that's using the defineComponent api, is there any guidance on being able to define components with generic props using the <script setup> syntax?

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants