I need to set an array with other data from an array, I have a couple of classes in typescript with which I make these arrays, mmm but I see that one field is of type number and the other is string, so I cannot set it, there is a way to set it or you have to change the type and leave it the same for the 2 classes
export class ListA
{
id: number;
name: string;
}
export class ListB
{
id: string;
name: string;
}
Example passing array B to A:
let userListB: ListB[] =
[
{
id: "1",
name: "John";
},
{
id: "2",
name: "Mike";
}
];
let milistaA: ListA[] = userListB;
//Obtengo un error de tipos porque el tipo de dato "id" no se puede convertir string a number
Any solution to this or definitively if the types have to be left the same