Closed AlvaroBrey closed 4 years ago
We state all options are valid in @Component
decorator factory function.
https://class-component.vuejs.org/guide/class-component.html#other-options
Where you mention is additional guide for TypeScript as decorator does not infer the type from decorator and props are unavailable on type level unless you explicitly declare it in class definition. If you prefer the explicit definition it's totally ok.
This was also unclear to me. The only place props is documented specifies this style of Vue.extend. I only found the @Component
style because of this github issue. The docs were confusing, which is my cue to trawl github issues. It looks like there's also @Props()
, which I found on accident with ide intellisense.
It'd be helpful to document these possibilities, maybe also a recommendation for preferred style?
@djeikyb @Prop
is provided by vue-property-decorator
, not by this lib.
Oh wow I didn't notice that it came from a repo outside the vuejs org.. I just started a typescript vue project with the vue cli tool, which I guess it comes with vue-property-decorator. I understand now why it's not mentioned in the vue-class-component docs!
The documentation suggests using
Vue.extend
to define props. However, defining the props in the decorator options and usingPropType
seems to work, and is more concise:Is there any reason why this is not recommended, or is the documentation just outdated (from when
PropType
didn't exist) ?