#angular #typescript
#angular #typescript
Вопрос:
Получение error TS2322: Type 'string | undefined' is not assignable to type 'never'
сообщения о том, что я пытался назначить 4 поля для этих 4 полей, отображалась ошибка TS2322
- ‘ObjectId’: current.ObjectId
- ‘LocationName’: loc.LocationName
- ‘attributeName’: attr.attributeName,
- ‘AttributeValue’: attr.AttributeValue
parseResponse(objects: empDetails): any {
return objects?.empList?.reduce((data, current: empList) => {
current?.locationDetails?.forEach(loc=> {
loc?.attributeDetails?.forEach(attr => {
data.push({
'objectId': current.objectId, 'locationName': loc.locationName, 'attributeName': attr.attributeName, 'attributeValue': attr.attributeValue
});
});
});
return data;
}, []);
}
Комментарии:
1. Каков ваш тип
empDetails
иempList
как он выглядит?
Ответ №1:
определение данных :
const data = [];
data.push({
'objectId': current.objectId, 'locationName': loc.locationName, 'attributeName': attr.attributeName, 'attributeValue': attr.attributeValue
});
});
});