Skip to content

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

@ebeloded

Description

@ebeloded

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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    RTDBOld Firebase realtime databasecontribution welcomeIf nobody has proposed a PR for this feature yet, feel free to comment and work on itfirestorenew Cloud Storetypescript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions