Open
Description
代码:
add(name: string): void {
name = name.trim();
if (!name) { return; }
this.heroService.addHero({name} as Hero)
.subscribe(hero => {this.heroes.push(hero); });
}
报错:
ERROR in src/app/component/heroes/heroes.component.ts(30,30): error TS2352: Conversion of type '{ name: string; }' to type 'Hero' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Property 'id' is missing in type '{ name: string; }'.