Check out a free preview of the full TypeScript 3 Fundamentals, v2 course:
The "Classes" Lesson is part of the full, TypeScript 3 Fundamentals, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Mike introduces how to create a class in TypeScript.

Get Unlimited Access Now

Transcript from the "Classes" Lesson

[00:00:00]
>> Mike North: The next topic we're going to jump into is classes. And you're probably familiar with using classes in regular JavaScript. TypeScript adds some new concepts on top of what you're used to. There is something new we need to think about in terms of class fields, and- TypeScript also introduces the concept of access modifier keywords.

[00:00:23] Which allow us to have control over who can see member data and member functions on instances. So let's go to the notes, to the 4-class-basic.ts file
>> Mike North: So in this example, you can see a couple things. The first is that we're using a new something I've been calling a heritage clause, right?

[00:00:58] Extends is the only thing that we can use to describe inheriting from another entity in JavaScript, that you can say class extends base class. TypeScript introduces implements, and that describes a class aligning with a particular interface. So HasEmail, we know this type requires that everything have a name that's a string and an email that's a string.

[00:01:27]
>> Mike North: What this means for any class that implements this interface, we have to make sure that these properties that conform to that interface are available and stated upfront. So, in terms of what this means up here, this is us declaring that these member data fields will exist. And their type is going to be a string.

[00:01:55] Here we're stating that we accept two parameters within our constructor, we accept two parameters. And down here, we are making sure that we pass the things our constructor receives onto the instance, which of course is this, within the constructor.