class Person {
constructor(public name: string) {}
}
class Manager extends Person {}
class Admin extends Person {}
class School {
constructor(public name: string) {}
}
function doOperation<T extends Person>(person: T): T {
return person;
}
let person = doOperation(new Manager("tars"));
let school = doOperation(new School("Harper's"));
why does typescript not throw any error in this case, when School class is clearly not a subclass of Person. Is it because both the classes (Person and School) have a property with same name.
public schoolName: stringand it will throw an error.