This course has been updated! We now recommend you take the TypeScript Fundamentals, v3 course.

Check out a free preview of the full TypeScript 3 Fundamentals, v2 course:
The "Address Book Exercise" 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:

Students are instructed to chance an address book file written in JavaScript to TypeScript.

Get Unlimited Access Now

Transcript from the "Address Book Exercise" Lesson

[00:00:00]
>> Mike North: Let's apply our newly learned three phase approach to converting a piece of JavaScript code into TypeScript. So I've written such an example for you. It's in the challenges folder under address book. And there's a little typo here that's not index.ts, it is index.js. The only file in the address book folder, so hopefully we'll figure that out.

[00:00:40]
>> Mike North: Let's take a look at this piece of code in order to understand the various aspects of it and where we might need to think about type information. So we've got a class here called AdressBook and we'll dig into that in a moment. We've got a function here called the formatDate, getFullName, and getVcardText.

[00:01:04] If you've never heard of Vcard, you can create a Vcard file, it's just a text file with contact information in it. And you can install this in your contacts app or something. In the AddressBook class, we have an array that looks like it's for contacts. A method to add contact, and then find a contact by name.

[00:01:29] So, the first of the three steps has us renaming this file from JS to TS, and setting the TypeScript compiler in a very loose mode until we can get things passing. Step 0 is making sure that the tests pass before and after we are done.
>> Mike North: Okay, 14 out of 14 tests passed.

[00:02:01] So, looks like we are good to get started.