Skip to content

Wrong type of 'this' inside firestore() context #399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ebeloded opened this issue Sep 20, 2019 · 2 comments
Closed

Wrong type of 'this' inside firestore() context #399

ebeloded opened this issue Sep 20, 2019 · 2 comments
Labels
contribution welcome If nobody has proposed a PR for this feature yet, feel free to comment and work on it firestore new Cloud Store RTDB Old Firebase realtime database typescript

Comments

@ebeloded
Copy link

ebeloded commented Sep 20, 2019

I am getting typing errors when trying to access props/methods of Vue instance inside of firestore function. In the example below, uid is a prop and I get no typing errors when accessing from created lifecycle hook, but it is not defined inside firestore function.

export default Vue.extend({

  props: ['uid'],

  created() {
    console.log({ uid: this.uid }) // this.uid is fine
  },

  firestore() {
    // Error: "Property 'uid' doesn't exist on type Vue"
    const uid = this.uid 
    return {
      user: db.doc(`users/${uid}`),
    }
  },
})

This can resolve the issue, but shouldn't be necessary:

const uid = (this as any).uid 
@posva posva added contribution welcome If nobody has proposed a PR for this feature yet, feel free to comment and work on it typescript labels Sep 21, 2019
@posva
Copy link
Member

posva commented Sep 21, 2019

Types are not added to the options of Vue.extend. This should be added to firebase as well

@posva posva added firestore new Cloud Store RTDB Old Firebase realtime database labels Sep 21, 2019
@posva
Copy link
Member

posva commented Nov 18, 2022

Things have changed in v3 in order to support Vue 2 and Vue 3 at the same time so this will only be the component instance with loose typings

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome If nobody has proposed a PR for this feature yet, feel free to comment and work on it firestore new Cloud Store RTDB Old Firebase realtime database typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants