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.

Basic types

Basic types

From the course: React: Using TypeScript (2019)

Start my 1-month free trial

Basic types

- The main function of TypeScript is to instill Inner Code best practices such as typing spections. We define what our application expects and validate it against the data we get. For example, if our component expects a value first name and we expect this value to be of a string, TypeScript will check this is the case and then warn us if it isn't. So let's explore the basic types of available with TypeScript with a few examples. The first thing I'm going to do is remove the lines from 14 to 21, and then what we'll do is edit the code on line 12 here. So what we're going to do is erase what's in here first, and then I'm going to say "The value" and then we're going to specify something once we created that value "is of" and then insert "type of" and then we'll insert the value "type", like so. And then let's go ahead and create just below the renders so we turn on line 6 and let's create our first value. So what we're going to do is create what "let first value" and this is how you…

Contents