I have a Vue component with a property defined using a decorator:
import { Component, Vue } from "vue-property-decorator"
@Component({
props: {
myId: String,
},
})
class TestProp extends Vue {
myFunction(obj: any) {
return obj[this.myId] // here tslint complains: "Property 'myId' does not exist on type 'TestProp'."
}
}
To avoid the type error, I currently use this workaround by converting this
to any
:
myFunction(obj: any) {
return obj[(this as any).myId]
}
However, this solution is more of a temporary fix than a permanent one.
It seems like the compiler may not be aware of properties defined by the @Component
decorator?
Any suggestions or ideas for solving this issue would be greatly appreciated.