(no title)
brlewis | 1 year ago
For example: https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABO...
class Animal {
isJaguar: boolean = false;
}
class Automobile {
isJaguar: boolean = false;
}
function engineSound(car: Automobile) {
return car.isJaguar ? "vroom" : "put put";
}
console.log(engineSound(42)); // TypeScript complains
console.log(engineSound(new Animal())); // TypeScript does not complain
mason55|1 year ago
Just add an Email class that also extends String and you can see that you can pass an Email to the compareHash function without it complaining.
https://www.typescriptlang.org/play/?#code/MYGwhgzhAEASkAtoF...jacobsimon|1 year ago