Can't use computed properties with TypeScript because of "Property '{prop_name}' does not exist on type 'Vue'." error
See original GitHub issueConsider the following code snippet:
import { Component, Vue } from "vue-property-decorator";
import { db } from "../../modules/firebase-client/";
import { DocumentReference } from "firebase/firestore";
@Component({
name: "SingleEntry",
firestore() {
return {
entry: db.collection("dashboard-entries").doc(this.$route.params.id),
queue: db.collection("tasks-queue").where("entryRef", "==", this.entryRef)
};
},
validations
})
export default class SingleEntry extends Vue {
get entryRef(): DocumentReference {
return db.collection("dashboard-entries").doc(this.$route.params.id);
}
}
the queue
property uses a computed value that’s returned by the entryRef
computed property. The code works (I can see proper results of the query rendered on the template), but TypeScript compiler is complaining that:
ERROR in /Users/wujekbogdan/htdocs/sw-rss-dashboard/src/views/SingleEntry/SingleEntry.vue
210:72 Property 'entryRef' does not exist on type 'Vue'.
208 | return {
209 | entry: db.collection("dashboard-entries").doc(this.$route.params.id),
> 210 | queue: db.collection("tasks-queue").where("entryRef", "==", this.entryRef)
| ^
211 | };
212 | },
213 | validations
Am I doing something wrong or is it a problem caused by incomplete/buggy typings declarations?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
In the TypeScript component, the error Property does not exist ...
When I run npm run build , an error Property 'pickerMap' does not exist on type 'Vue'. The complete prompt is as follows:...
Read more >Resolve "Property does not exist on type 'Vue'" error
Have the same issue. solution is to add a return type on each computed variable. Issue from this code ...
Read more >Props | Vue.js
For each property in the object declaration syntax, the key is the name of the prop, while the value should be the constructor...
Read more >Documentation - TypeScript 4.3
When considering how two properties with the same name relate to each other, TypeScript will only use the “reading” type (e.g. the type...
Read more >Window.getComputedStyle() - Web APIs | MDN
Shorthand names like font will not work with most browsers. CSS property values may be accessed using the getPropertyValue(propName) API or by ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi.
You need to write like this, for example
I really don’t know, the type declaration file is here: https://github.com/vuejs/vuefire/blob/lerna/packages/vuefire/types/vue.d.ts#L33 and we did add the
this