Can you assist me in converting this class into TypeScript and explaining why it's not functioning?
class Students {
public name: string;
public surname: string;
public age: number;
}
constructor(name:string,surname:string,age:number) {
this.name = name;
this.surname = surname;
this.age = age;
}
public updateStudentInfo(name:string, surname:string,age:number):void {
this.name = typeof name !== 'undefined' ? name : this.name;
this.surname = typeof surname !== 'undefined' ? surname : this.surname;
this.age = typeof age !== 'undefined' ? age : this.age;
}
public studentInfoToString():object{} {
return `\nName: ${this.name}, Surname: ${this.surname} Age: ${this.age}`
}
let student1 = new Students("Aladin","Indus", 20);
console.log(student1.studentInfoToString());