From the course: TypeScript: Object-Oriented Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Inheritance

Solution: Inheritance

From the course: TypeScript: Object-Oriented Programming

Start my 1-month free trial

Solution: Inheritance

(upbeat music) - [Instructor] So I'm going to go ahead and actually close this User class just 'cause it takes up quite a bit of the screen and we'll start with our Admin class here. Now, our Admin class is going to extend User. Now, as in step four, we said hey, we want a constructor and notice at the get go, we have this error, right? That's because when we have a derived class or a child class, we want to call super here. Now, there's no constructor in our User class, so we don't need to pass any values to it. If we do, we would. In our case, all we're going to do here is paste in a firstName: string, a lastName: string and an email that is a string to pass our values to it. Now, once thing is we'll go and reset these values so that when we construct our admin, we have the ability to. You'll notice, when I move this to above super that we get this error that's basically saying hey, super always has to…

Contents