necesito crear una matriz, pero el tipo de objeto es diferente dependiendo de una condición, algo como esto:
myList = condition() ? Array < { secondLabel: String, value: String } > [] : Array < { label: String, value: Number } > []pero estoy recibiendo estos errores:
Cannot compare class Array [1] to object literal [2]. Cannot compare boolean [1] to empty array literal [2].¡Solo usa el constructor de matrices!
const myList = true ? new Array<{ secondLabel: String, value: String }>() : new Array<{ label: String, value: Number }>()o puede afirmar el tipo:
const myList = condition() ? [] as Array<{ secondLabel: String, value: String }> : [] as Array<{ label: String, value: Number }>