In order to avoid this, you could as well initialize the selectedHero
member of your component to an empty object (instead of leaving it undefined).
In your example code, that would give something like this :
export class AppComponent {
title = 'Tour of Heroes';
heroes = HEROES;
selectedHero:Hero = new Hero();
onSelect(hero: Hero):void{
this.selectedHero = hero;
}
}