Currently, I am utilizing Vue in combination with TypeScript along with the 'vue-property-decorator' package.
When attempting to utilize a prop as shown below:
@Prop({ default: '' }) private type: string
An error is triggered by the TS compiler stating:
Property 'type' has no initializer and is not definitely assigned in the constructor.
However, if I provide an initialization like this:
@Prop({ default: '' }) private type: string = ''
A warning appears in the browser console:
vue.runtime.esm.js?ff9b:587 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "type"
In such a situation, what steps should I take to prevent any errors or warnings?
The only solution that comes to mind is setting
"strictPropertyInitialization": false
in tsconfig.json, although I would prefer to avoid doing so if feasible.
Thank you!