Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Not all code paths return a value.ts(7030) angular

  data:any;
  submit() {
    this.answersValue.forEach((x: { forms: any[]; }) => {
      this.data = {
        pluginconfigform: "pluginconfigform",
        answers: x.forms.map(y => {
          if (y.type != "description") {
            return {
              sectionItemCode: y.code,
              answer: y.answer
            };
          } else {
            delete this.data.answers;
          }
        })
      };
      this.pushData(this.data);
    });
  }

could you let me know how to solve this error? ‘Not all code paths return a value.’ Thank you.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Add a return y (or undefined, or anything else conform your other return) after delete this.data.answers;. You’re using map so you need to return an object that gets mapped back. If you don’t want or need to return anything then return undefined so it’ll disappear.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading