Skip to content

Commit e239941

Browse files
gkalpakmhevery
authored andcommitted
docs: make HeroService#gerHero() in toh-pt5 compatible with TS strict mode (angular#41234)
Fixes angular#41207 PR Close angular#41234
1 parent 6d47b05 commit e239941

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

aio/content/examples/toh-pt5/src/app/hero.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export class HeroService {
1919

2020
// #docregion getHero
2121
getHero(id: number): Observable<Hero> {
22-
const hero = HEROES.find(h => h.id === id);
22+
// For now, assume that a hero with the specified `id` always exists.
23+
// Error handling will be added in the next step of the tutorial.
24+
const hero = HEROES.find(h => h.id === id) as Hero;
2325
this.messageService.add(`HeroService: fetched hero id=${id}`);
2426
return of(hero);
2527
}

0 commit comments

Comments
 (0)