Most of the time, when I use this
inside a method on my vue object, it correctly gets the type CombinedVueInstance
. However, there are instances where it is assigned types like Vue
when accessing this
in a method, and Accessors<DefaultComputed>
when using it in a computed method, even though everything appears to be the same. The code snippet below illustrates this issue:
import Vue, { PropType } from 'vue'
export default Vue.extend({
props: {
field: Object as PropType<FieldType>,
row: Boolean as PropType<boolean>,
events: Object,
},
data() {
return {
value: undefined,
}
},
computed: {
required() {
return this.field.required && !this.value
},
invalid() {
return this.field.isValid && !this.field.isValid(this.value)
}
},
Can you explain why this
does not always receive the type CombinedVueInstance
within the Vue component object?