From the course: TypeScript Essential Training
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Challenge: Types - TypeScript Tutorial
From the course: TypeScript Essential Training
Challenge: Types
(upbeat electronic music) - [Instructor] In this chapter, I introduced you to a number of ways to apply types to your JavaScript code. For this challenge, I've given you a JavaScript application in your exercise files. I've already created the tsconfig.json file, but your challenge is to find a place to apply each of the techniques that I've shown you in this chapter. First, create an interface to describe the structure of this variable. Hint: It's an array. So you want to define the interface for the type of items that are in the array, not the whole array. Next, I want you to strongly type some hard-coded values with an enum. Then, apply types to the parameters and return values of these functions. And also, use a generic parameter to define the parameter type of this function. This one will probably take you a little bit longer to finish. You might be able to finish it in under 15 minutes, but don't be…
Contents
-
-
-
-
Primitives and built-in types4m 29s
-
(Locked)
Creating custom types with interfaces6m 2s
-
(Locked)
Defining types using type aliases2m 14s
-
(Locked)
Defining enumerable types3m 30s
-
(Locked)
Typing functions3m 47s
-
(Locked)
Defining a metatype using generics6m 34s
-
(Locked)
Challenge: Types1m 5s
-
(Locked)
Solution: Types4m 31s
-
-
-
-
-