Subscribe on changes!

defineProps: bad type generated

avatar
Jul 19th 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.