Quería verificar si hay una propiedad en una matriz de objetos que tiene un valor nulo, si es así, devuelve verdadero.
Actualmente mi problema es
This condition will always return 'false' since the types '{ type: any; startDate: string; endDate: string; annualRent: any; }' and 'string' have no overlap.ts(2367)#código actual para comprobar la propiedad vacía
const hasEmptyRentSchedProperty = Object.values((this.proposedRentSchedule)).some((v => v === null || v === ""))#object = this.proposedRentSchedule
[ { "type": 0, "startDate": "2022-1-4", "endDate": "2022-1-19", "annualRent": "232" }, { "type": 0, "startDate": "2022-1-20", "endDate": "2022-1-20", "annualRent": null } ]La razón por la que obtiene ese error es porque está obteniendo los valores de la matriz cuyo tipo es { type: any; startDate: string; endDate: string; annualRent: any; } y no solo una string . En este caso, ¿cómo funciona una comparación de cadenas? Eso es lo que señala Typescript.
var data = [ { "type": 0, "startDate": "2022-1-4", "endDate": "2022-1-19", "annualRent": "232" }, { "type": 0, "startDate": "2022-1-20", "endDate": "2022-1-20", "annualRent": null } ] console.log(data.some(element => Object.values(element).some(val => val === null || val === "")))