question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use computed properties with TypeScript because of "Property '{prop_name}' does not exist on type 'Vue'." error

See original GitHub issue

Consider 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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
kaorun343commented, Oct 10, 2018

Hi.

You need to write like this, for example

@Component<SingleEntry>({
  firestore() {
    this
  }
})
export default class SingleEntry extends Vue {}
1reaction
posvacommented, Sep 15, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found