Document error about defining the default value of Object type props
You can define the Object type props like this. It will work fine.
export default defineComponent({
props: {
newProp: {
type: Object
default: () => {
return {
a: 1
}
}
}
}
})
But if you define the prop like this, it will throw a type error.
export default defineComponent({
props: {
newProp: {
type: Object
default() {
return {
a: 1
}
}
}
}
})
The documentation shows a code similar to the second paragraph.
I believe the examples in the documentation are correct, though there are some considerations when adapting them to TypeScript:
https://v3.vuejs.org/guide/typescript-support.html#annotating-props
Maybe we should include the above link in that earlier guide?
@skirtles-code I believe we should add a note to the TS guide rather than to the default (as default works in the non-TS environment). Alternatively, we can change all examples to use arrow functions from the starts - this will resolve the concern without adding anything to TS guide
