docs: make `HeroService#gerHero()` in `toh-pt5` compatible with TS strict mode (#41234)

Fixes #41207

PR Close #41234
This commit is contained in:
George Kalpakas 2021-03-16 23:31:19 +02:00 committed by Misko Hevery
parent 6d47b05b5b
commit e23994191c
1 changed files with 3 additions and 1 deletions

View File

@ -19,7 +19,9 @@ export class HeroService {
// #docregion getHero
getHero(id: number): Observable<Hero> {
const hero = HEROES.find(h => h.id === id);
// For now, assume that a hero with the specified `id` always exists.
// Error handling will be added in the next step of the tutorial.
const hero = HEROES.find(h => h.id === id) as Hero;
this.messageService.add(`HeroService: fetched hero id=${id}`);
return of(hero);
}