Why does the code below compile fine when the variable id is declared as an number, when within the constructor it is being assigned a string?
interface IComplexType{
id: number;
name: string;
}
class ComplexType implements IComplexType{
id: number;
name: string;
constructor(idArg: number, nameArg: string);
constructor(idArg: string, nameArg: string);
constructor(idArg: any, nameArg: any){
this.id = idArg;
this.name = nameArg;
}
}
window.onload = () =>{
var complexType: ComplexType = new ComplexType("hi","hi");
console.log(complexType.id);
}
Thanks!