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: bad type generated #4146

Closed
jods4 opened this issue Jul 19, 2021 · 0 comments · Fixed by #4147
Closed

defineProps: bad type generated #4146

jods4 opened this issue Jul 19, 2021 · 0 comments · Fixed by #4147
Labels

Comments

@jods4
Copy link
Contributor

jods4 commented Jul 19, 2021

Version

3.2.0-beta.1

Reproduction link

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8Q29tcCA6eD1cImZcIj48L0NvbXA+XG48L3RlbXBsYXRlPlxuXG48c2NyaXB0IHNldHVwPlxuICBpbXBvcnQgQ29tcCBmcm9tIFwiLi9Db21wLnZ1ZVwiO1xuXG5cdGZ1bmN0aW9uIGYoKSB7IHJldHVybiB0cnVlOyB9XG48L3NjcmlwdD4iLCJDb21wLnZ1ZSI6Ijx0ZW1wbGF0ZT5cbiAgaGVsbG9cbjwvdGVtcGxhdGU+XG5cbjxzY3JpcHQgc2V0dXAgbGFuZz1cInRzXCI+XG5cdGRlZmluZVByb3BzPHtcbiAgICB4OiAoKGl0ZW06IGFueSkgPT4gYm9vbGVhbikgfCBudWxsO1xuICB9PigpO1xuPC9zY3JpcHQ+In0=

Steps to reproduce

In script-setup, defineProps a property of type ((x: any) => boolean) | null.
The repro above fails to execute, look at the Comp.vue JS tab for insight.

What is expected?

It works!

What is actually happening?

As can be seen in repro, SFC compiler generates type: [null, null] instead of type: [Function, Object].
Then at runtime, Vue crashes in assertType because it tries to do value instanceof type with type = null.

@LinusBorg LinusBorg added 🐞 bug Something isn't working scope: script-setup labels Jul 19, 2021
yyx990803 added a commit that referenced this issue Jul 19, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants