name1: any;
name2: any[];
this.name1 = this.name2;
If you use any
, both on the left and on the right side of an assignment, you are basically say to Typescript not use type checking.
In any
is on left side it means the the variable you want to assign the value can accept any type, and therefore it accepts anything including an object of type any[]
.
If the type any
is on the right side and you have myVar: any[]
on the left side, you are basically say to Typescript not use type checking. Considering that type checking is not applied at run time, you would end up with myVar
being filled with whatever you may have on the right side of the assignment.