From the course: React: Using TypeScript (2019)

Unlock the full course today

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

Other complex types

Other complex types

From the course: React: Using TypeScript (2019)

Start my 1-month free trial

Other complex types

- [Instructor] We've explored some basic types, now let's go and take a look at other complex types. First thing we're going to do is erase all this so we can get some space to work here, so if you want to take a look at these later on, you can take a look at the exercise files. So, the first thing we're going to do is aTuple, so I'm going to first put the syntax and then explain what it is. So, let's go and do a let aTuple and then we'll declare it with an array and then initialize it with some values. So, basically aTuple is a type of array that you can insert multiple types and let me just add some stuff here to make a little bit more sense. So, in this type of array, you can actually have more than one type. So, typically in JavaScript you can do whatever you want in an array, so you can add anything you want, however, in TypeScript you have to define it first and then the array has to be exactly what that declaration is, so for example, if you declare an array as a string, all of…

Contents