Tech Challenge
2026-07-08
🔷
Daily Tech Challenge
TypeScript
medium
Question 1 of 5
Given the class union below, what does the TypeScript compiler do with animal.bark() and animal.meow()?
Example
class Dog { bark() { return "woof"; } }
class Cat { meow() { return "meow"; } }
function speak(animal: Dog | Cat): string {
if (animal instanceof Dog) {
return animal.bark();
}
return animal.meow();
}Wednesday, July 8, 2026 · A new challenge drops every day