When I use provide/inject
with class components everything works as expected. But when I use it in a "normal" vue component I get type-errors.
In this example I get errors when referencing this.testService
. The code works though.
export default Vue.extend({
name: "HelloWorldBasic" as string,
inject: ["testService"],
computed: {
message(): string | null {
return this.testService ? this.testService.hello() : null;
}
}
});
Where did I make my mistake? How should I write the code?
I set up a small project to be able to reproduce it and work with it:
$ git clone [email protected]:schnetzi/vue-provide-inject.git
$ npm ci
$ npm start