Reputation: 49
When I upgrade from angular 8 to angular 9, I am getting a wired error saying that "Type 'string[]' is not assignable to type 'string'." when I run "npm install", below is the code that is getting this error.
let A = "";
if(error instanceof HttpErrorResponse){
...
}else{
B.fromError(error).then(errors => {
A = errors.splice(0, 5).map(function(re) {
return res.toString();
});
console.log(A);
}
Upvotes: 0
Views: 1471
Reputation: 4922
On the first line you declare A
as an empty string
:
let A = "";
Then you try to assign A
the value of errors
, which is an Array
A = errors.splice(0, 5).map(function(re) {
return res.toString();
});
You can't do that. Maybe replace the first line with:
let A: any[] = [];
Or replace any
with whatever type the elements of errors
are supposed to be.
Upvotes: 1
Reputation: 139
It sounds odd to declare variable A
as a string (initializing it to an empty string) and later in the else
statement, you're assigning it a string array.
Upvotes: 1