Typescript Error Property 'members' does not exist on type '{}'











up vote
0
down vote

favorite












This piece of code has been working well until a few days ago when I upgraded angularfire and firebase:
From "angularfire2": "5.0.0-rc.4", to "angularfire2": "^5.1.0",
from "firebase": "4.8.0", to "firebase": "^5.5.7":



this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
this.group = group.payload.val();
this.groupMembers = null;
// Get group members
if (group.payload.val().members) {
group.payload.val().members.forEach((memberId) => {
this.dataProvider.getUser(memberId).snapshotChanges().subscribe((member) => {
this.addOrUpdateMember(member);
});
});
// Get user's contacts to add
this.dataProvider.getCurrentUser().snapshotChanges().subscribe((account) => {
if (account.payload.val().contacts) {

//Delete log
console.log('My contacts',account.payload.val().contacts);
for (var i = 0; i < account.payload.val().contacts.length; i++) {
this.dataProvider.getUser(account.payload.val().contacts[i]).snapshotChanges().subscribe((contact) => {
// Only contacts that are not yet a member of this group can be added.

contact = { $key: contact.key, ...contact.payload.val()};
//Delete log
console.log('Is contact',contact,' already added?',this.isMember(contact));
if (!this.isMember(contact))
this.addOrUpdateContact(contact);
});
}
if (!this.contacts) {
this.contacts = ;
}
} else {
this.contacts = ;
}
});
}
this.loadingProvider.hide();
});


This is the getGroup() in the provider:



getGroup(groupId) {
return this.angularfire.object('/groups/' + groupId);
}


It is bringing this error everywhere there is payload.val().someProperty in the project.










share|improve this question




























    up vote
    0
    down vote

    favorite












    This piece of code has been working well until a few days ago when I upgraded angularfire and firebase:
    From "angularfire2": "5.0.0-rc.4", to "angularfire2": "^5.1.0",
    from "firebase": "4.8.0", to "firebase": "^5.5.7":



    this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
    this.group = group.payload.val();
    this.groupMembers = null;
    // Get group members
    if (group.payload.val().members) {
    group.payload.val().members.forEach((memberId) => {
    this.dataProvider.getUser(memberId).snapshotChanges().subscribe((member) => {
    this.addOrUpdateMember(member);
    });
    });
    // Get user's contacts to add
    this.dataProvider.getCurrentUser().snapshotChanges().subscribe((account) => {
    if (account.payload.val().contacts) {

    //Delete log
    console.log('My contacts',account.payload.val().contacts);
    for (var i = 0; i < account.payload.val().contacts.length; i++) {
    this.dataProvider.getUser(account.payload.val().contacts[i]).snapshotChanges().subscribe((contact) => {
    // Only contacts that are not yet a member of this group can be added.

    contact = { $key: contact.key, ...contact.payload.val()};
    //Delete log
    console.log('Is contact',contact,' already added?',this.isMember(contact));
    if (!this.isMember(contact))
    this.addOrUpdateContact(contact);
    });
    }
    if (!this.contacts) {
    this.contacts = ;
    }
    } else {
    this.contacts = ;
    }
    });
    }
    this.loadingProvider.hide();
    });


    This is the getGroup() in the provider:



    getGroup(groupId) {
    return this.angularfire.object('/groups/' + groupId);
    }


    It is bringing this error everywhere there is payload.val().someProperty in the project.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      This piece of code has been working well until a few days ago when I upgraded angularfire and firebase:
      From "angularfire2": "5.0.0-rc.4", to "angularfire2": "^5.1.0",
      from "firebase": "4.8.0", to "firebase": "^5.5.7":



      this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
      this.group = group.payload.val();
      this.groupMembers = null;
      // Get group members
      if (group.payload.val().members) {
      group.payload.val().members.forEach((memberId) => {
      this.dataProvider.getUser(memberId).snapshotChanges().subscribe((member) => {
      this.addOrUpdateMember(member);
      });
      });
      // Get user's contacts to add
      this.dataProvider.getCurrentUser().snapshotChanges().subscribe((account) => {
      if (account.payload.val().contacts) {

      //Delete log
      console.log('My contacts',account.payload.val().contacts);
      for (var i = 0; i < account.payload.val().contacts.length; i++) {
      this.dataProvider.getUser(account.payload.val().contacts[i]).snapshotChanges().subscribe((contact) => {
      // Only contacts that are not yet a member of this group can be added.

      contact = { $key: contact.key, ...contact.payload.val()};
      //Delete log
      console.log('Is contact',contact,' already added?',this.isMember(contact));
      if (!this.isMember(contact))
      this.addOrUpdateContact(contact);
      });
      }
      if (!this.contacts) {
      this.contacts = ;
      }
      } else {
      this.contacts = ;
      }
      });
      }
      this.loadingProvider.hide();
      });


      This is the getGroup() in the provider:



      getGroup(groupId) {
      return this.angularfire.object('/groups/' + groupId);
      }


      It is bringing this error everywhere there is payload.val().someProperty in the project.










      share|improve this question















      This piece of code has been working well until a few days ago when I upgraded angularfire and firebase:
      From "angularfire2": "5.0.0-rc.4", to "angularfire2": "^5.1.0",
      from "firebase": "4.8.0", to "firebase": "^5.5.7":



      this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
      this.group = group.payload.val();
      this.groupMembers = null;
      // Get group members
      if (group.payload.val().members) {
      group.payload.val().members.forEach((memberId) => {
      this.dataProvider.getUser(memberId).snapshotChanges().subscribe((member) => {
      this.addOrUpdateMember(member);
      });
      });
      // Get user's contacts to add
      this.dataProvider.getCurrentUser().snapshotChanges().subscribe((account) => {
      if (account.payload.val().contacts) {

      //Delete log
      console.log('My contacts',account.payload.val().contacts);
      for (var i = 0; i < account.payload.val().contacts.length; i++) {
      this.dataProvider.getUser(account.payload.val().contacts[i]).snapshotChanges().subscribe((contact) => {
      // Only contacts that are not yet a member of this group can be added.

      contact = { $key: contact.key, ...contact.payload.val()};
      //Delete log
      console.log('Is contact',contact,' already added?',this.isMember(contact));
      if (!this.isMember(contact))
      this.addOrUpdateContact(contact);
      });
      }
      if (!this.contacts) {
      this.contacts = ;
      }
      } else {
      this.contacts = ;
      }
      });
      }
      this.loadingProvider.hide();
      });


      This is the getGroup() in the provider:



      getGroup(groupId) {
      return this.angularfire.object('/groups/' + groupId);
      }


      It is bringing this error everywhere there is payload.val().someProperty in the project.







      typescript firebase ionic3 angularfire2 angularfire






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 11:24









      Grimthorr

      4,28942035




      4,28942035










      asked Nov 9 at 7:57









      Paul Kitatta

      163




      163
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          Here is how I get the data from firebase.



          firebase.database().ref('/MyCustomFolder').once("value").then(snapshot => {
          let data = snapshot.val();
          console.log(data.customers);
          });


          I suggest trying the following:



          this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
          let data = group.val();
          let payload = data.payload;
          if (payload.members) {
          /* do something */
          }





          share|improve this answer























          • Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
            – Paul Kitatta
            Nov 9 at 13:14










          • @PaulKitatta I think i did a mistake. I edited my answer
            – Dmitry Stepanov
            Nov 12 at 9:55












          • it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
            – Paul Kitatta
            Nov 12 at 11:26


















          up vote
          0
          down vote



          accepted










          This is what I had to do to get it working:



          this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
          let data: any = group.payload.val();
          if (data.members) {
          /* do something */
          }


          So apparently I had to include : any. Again, given that is was working before I made the upgrade - the experts will tell us more of the cause.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221792%2ftypescript-error-property-members-does-not-exist-on-type%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            Here is how I get the data from firebase.



            firebase.database().ref('/MyCustomFolder').once("value").then(snapshot => {
            let data = snapshot.val();
            console.log(data.customers);
            });


            I suggest trying the following:



            this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
            let data = group.val();
            let payload = data.payload;
            if (payload.members) {
            /* do something */
            }





            share|improve this answer























            • Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
              – Paul Kitatta
              Nov 9 at 13:14










            • @PaulKitatta I think i did a mistake. I edited my answer
              – Dmitry Stepanov
              Nov 12 at 9:55












            • it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
              – Paul Kitatta
              Nov 12 at 11:26















            up vote
            0
            down vote













            Here is how I get the data from firebase.



            firebase.database().ref('/MyCustomFolder').once("value").then(snapshot => {
            let data = snapshot.val();
            console.log(data.customers);
            });


            I suggest trying the following:



            this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
            let data = group.val();
            let payload = data.payload;
            if (payload.members) {
            /* do something */
            }





            share|improve this answer























            • Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
              – Paul Kitatta
              Nov 9 at 13:14










            • @PaulKitatta I think i did a mistake. I edited my answer
              – Dmitry Stepanov
              Nov 12 at 9:55












            • it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
              – Paul Kitatta
              Nov 12 at 11:26













            up vote
            0
            down vote










            up vote
            0
            down vote









            Here is how I get the data from firebase.



            firebase.database().ref('/MyCustomFolder').once("value").then(snapshot => {
            let data = snapshot.val();
            console.log(data.customers);
            });


            I suggest trying the following:



            this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
            let data = group.val();
            let payload = data.payload;
            if (payload.members) {
            /* do something */
            }





            share|improve this answer














            Here is how I get the data from firebase.



            firebase.database().ref('/MyCustomFolder').once("value").then(snapshot => {
            let data = snapshot.val();
            console.log(data.customers);
            });


            I suggest trying the following:



            this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
            let data = group.val();
            let payload = data.payload;
            if (payload.members) {
            /* do something */
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 12 at 9:50

























            answered Nov 9 at 12:11









            Dmitry Stepanov

            1766




            1766












            • Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
              – Paul Kitatta
              Nov 9 at 13:14










            • @PaulKitatta I think i did a mistake. I edited my answer
              – Dmitry Stepanov
              Nov 12 at 9:55












            • it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
              – Paul Kitatta
              Nov 12 at 11:26


















            • Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
              – Paul Kitatta
              Nov 9 at 13:14










            • @PaulKitatta I think i did a mistake. I edited my answer
              – Dmitry Stepanov
              Nov 12 at 9:55












            • it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
              – Paul Kitatta
              Nov 12 at 11:26
















            Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
            – Paul Kitatta
            Nov 9 at 13:14




            Thanks @Dmitry for response. But is I change then I get a new error: Typescript Error Property 'members' does not exist on type 'DatabaseSnapshot<{}>'. Property 'members' does not exist on type 'DatabaseSnapshotExists<{}>'.
            – Paul Kitatta
            Nov 9 at 13:14












            @PaulKitatta I think i did a mistake. I edited my answer
            – Dmitry Stepanov
            Nov 12 at 9:55






            @PaulKitatta I think i did a mistake. I edited my answer
            – Dmitry Stepanov
            Nov 12 at 9:55














            it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
            – Paul Kitatta
            Nov 12 at 11:26




            it gives new error: Property 'val' does not exist on type 'AngularFireAction<DatabaseSnapshot<{}>>'.. But I found solution.
            – Paul Kitatta
            Nov 12 at 11:26












            up vote
            0
            down vote



            accepted










            This is what I had to do to get it working:



            this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
            let data: any = group.payload.val();
            if (data.members) {
            /* do something */
            }


            So apparently I had to include : any. Again, given that is was working before I made the upgrade - the experts will tell us more of the cause.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              This is what I had to do to get it working:



              this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
              let data: any = group.payload.val();
              if (data.members) {
              /* do something */
              }


              So apparently I had to include : any. Again, given that is was working before I made the upgrade - the experts will tell us more of the cause.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                This is what I had to do to get it working:



                this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
                let data: any = group.payload.val();
                if (data.members) {
                /* do something */
                }


                So apparently I had to include : any. Again, given that is was working before I made the upgrade - the experts will tell us more of the cause.






                share|improve this answer












                This is what I had to do to get it working:



                this.dataProvider.getGroup(this.groupId).snapshotChanges().subscribe((group) => {
                let data: any = group.payload.val();
                if (data.members) {
                /* do something */
                }


                So apparently I had to include : any. Again, given that is was working before I made the upgrade - the experts will tell us more of the cause.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 at 11:34









                Paul Kitatta

                163




                163






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53221792%2ftypescript-error-property-members-does-not-exist-on-type%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Landwehr

                    Reims

                    Javascript gets undefined on array