Answer the question
In order to leave comments, you need to log in
Does it make sense to do @Prop typing?
@Prop({required: true, type: String}) public readonly icon!: string;
Answer the question
In order to leave comments, you need to log in
If the emitDecoratorMetadata ts-flag is set, then vue-property-decorator will automatically set type for a simple primitive type, i.e. specifically here you can not specify manually. However, if the type is complex or a union of simple ones, then this will no longer work, and then it must be done manually. (I have an unfinished ts-transformer plugin lying around to extend this behavior, but I still can’t get my hands on it.)
This is about the interaction of ts and vue.
If the question is "should vue-typing properties be necessary at all", then the answer is generally: up to you.
There are two reasons to do this:
1. Using your component outside of the ts environment.
2. The behavior of a property whose first type is Boolean
different from the usual one: such a property is set totrue
if it is on a component, even if the value is missing:
<component boolean-prop></component>
// если type: Boolean - booleanProp === true
// если type иной или отсутствует - booleanProp === undefined
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question