Skip to content

Hero-Detail Component generates error TS2345 #42114

Closed

Description

@easybreather

Docs or angular.io Bug Report

have checked bug reports, nothing covering this issue (although one report corrected text)

Description

Build at: 2021-05-16T10:10:23.359Z - Hash: 37830322103468919099 - Time: 379ms
Error: src/app/hero-detail/hero-detail.component.ts:37:33 - error TS2345: Argument of type 'Hero | undefined' is not assignable to parameter of type 'Hero'.
Type 'undefined' is not assignable to type 'Hero'.

37 this.heroService.updateHero(this.hero)
~~~~~~~~~

Minimal Reproduction

export class HeroDetailComponent implements OnInit {
...
save(): void {

// there is an error here (this.hero) that is not understood
// @see 	https://angular.io/tutorial/toh-pt6
this.heroService.updateHero(this.hero)
  .subscribe(() => this.goBack());

}
...

for now, cannot "update" the hero name. have commented out the updateHero() for now... (I believe you that it works...)

Reproduction Steps**

am following the demo process

Expected vs Actual Behavior**

Your Environment

win10pro, opera v75

Anything else relevant?

following the demo using latest npm v12 angular stuff

Activity

  1. JoostK commented on May 16, 2021

    @JoostK
    Member

    This is being addressed in #41999.

  2. added this to the needsTriage milestone on May 16, 2021
  3. JoostK commented on May 17, 2021

    @JoostK
    Member

    Closing this as #41999 was merged.

  4. angular-automatic-lock-bot commented on Jun 17, 2021

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions