Open
Description
Vue version
3.4.27
Link to minimal reproduction
Steps to reproduce
Create a component with defineComponent
that has a prop with a default function e.g.
export default defineComponent({
data() {
return {
dataOne: "Hello World From Data"
}
},
props: {
propOne: String,
propTwo: {
type: String,
default() { // <-- this causes invalid prop types in the template
return '';
}
}
}
});
What is expected?
Correct prop types in the template
What is actually happening?
Invalid prop types, looks like it's showing array values as prop types
System Info
No response
Any additional comments?
Originally posted in volar repo, but requested to post here instead: vuejs/language-tools#3323
Activity
ferreraa commentedon May 17, 2024
The problem seems to be related to the function syntax used.
A workaround to the issue is to define your default function that way
default: () => { return ''; }
linzhe141 commentedon May 20, 2024
When I comment out the
data
function, it worksOr when my
data
function is writtenafter props
, it will also work.