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
From the course: TypeScript: Object-Oriented Programming
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Inheritance introduction1m 54s
-
(Locked)
Extending classes in TypeScript2m 40s
-
(Locked)
Implementing classes in TypeScript1m 22s
-
(Locked)
Super()3m 43s
-
(Locked)
Super() overrides1m 56s
-
(Locked)
Generics2m 46s
-
(Locked)
Polymorphism3m 8s
-
(Locked)
Challenge: Inheritance59s
-
(Locked)
Solution: Inheritance3m 10s
-
-
-