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.
CodePudding user response:
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.