Hey welcome to this new Typescript course. So in this 1
course we're going to discover Typescript language and I will 2
assume that you don't know anything about it obviously but 3
I would just assume that you have some basic knowledges with 4
JavaScript, HTML and CSS. So if you are here today it's 5
probably because you've heard that Typescript is quite famous 6
is probably... You probably heard that it's used a lot by 7
developers in companies in professional project etc... 8
and probably also that it's related to JavaScript closely 9
related to JavaScript. All of that is true. But we're going 10
to see exactly what typescript is. So typescript is what we 11
call a JavaScript superset. It just means that anything that 12
you have in JavaScript you will also have it with typescript 13
but you're just going to have other features, additional 14
features with typescript like the typing system. We're going 15
to see what this is exactly after but what you have to 16
remember is that any value JavaScript code is valid typescript 17
code, okay? So you can use typescript and just write 18
JavaScript and you will be fine, everything is going to 19
work as expected. But the cool thing is that you will have 20
other features. You have to understand that typescript is a 21
tool for developers only meaning that it's for example 22
not going to improve the performances of your 23
application okay it's not going to make it faster but it's 24
going to help you produce less errors while writing code for 25
example it's going to make your code easier to understand easier 26
to maintain but it's definitely not going to make your code 27
faster, and this is because in the end actually when you're 28
writing typescripts it's just going to produce javascript. This 29
is because typescript is not understood at all for example 30
by the browsers, so you're never going to to see some type 31
script code behind the scene running if you inspect the code 32
in your browser and this is because it will be compiled 33
into JavaScript so you're just going to see some JavaScript 34
and that is one reason of why for example is not going to 35
make your application faster because in the end it's just 36
JavaScript okay so type script is just for you while you are 37
coding. (very important). Now one of the main difference between typescript 38
and JavaScript is when it's running. When it's going to 39
check if something is wrong in your code. With JavaScript the 40
code is going to be executed and tested when it's running, 41
when it's finally running when your app is running. And this 42
means that you're going to see the errors only once your app 43
is running and maybe for example crashing if something 44
is wrong. You probably notice that you have an error in your 45
JavaScript code the page is just going to become a white 46
page and you will have a red error in your console while 47
Typescript has something called the static type checking 48
meaning that you're going to be able to see the errors before 49
you run the code so for example you will be able to see them 50
while you're coding you will be able to see them in your 51
favorite code editor. So let me give you an example. Let's say 52
on the left we have some JavaScript code and on the 53
right here we have some type script code. And yes, it's 54
exactly the same code and this is because you remember any 55
JavaScript code that is valid is also valid type script code. 56
Yep. So for now I haven't written anything that is 57
specific to Typescript for now it's just JavaScript code 58
Now what is going to happen if you run this code well 59
obviously here you have declared a name that is a 60
string okay and after that you're trying to run it like if 61
it's a function so this is obviously nothing right and 62
this is going to produce an error at some point and with 63
JavaScript well you're just going to see your error when 64
your application is going to run okay so JavaScript is not 65
going to see anything when you're going to write the code. 66
It's going to say yeah sure, write that, maybe it's going to 67
crash, maybe not, who knows? You will at some point. Uh 68
While with Typescript, well if you use typescript, in your code 69
editor, you will see that this little piece of code is going 70
to be underlined in red for example and in your terminal 71
well type script is going to cry and say no, this is wrong, 72
you should not write this, this is not a function, this is a 73
string, you cannot call that as a function. And this is going 74
to make a huge difference while you are coding because for now 75
here this example is very simple but let's say that 76
actually this error here is actually wrapped into a 77
condition that is satisfied very rarely , so you almost 78
never enter in this condition just imagine one second that 79
this code is running in production maybe it will take I 80
don't know two three months before a user end up in this 81
condition and this error could stay unnoticed for a very 82
long time and it's only in three months that you will 83
final notice that "Oh no I have an error in my code now it's 84
crashing the users cannot access the page anymore" And 85
it's too late. While with typescript you would have been 86
notified instantly while writing the code you don't have 87
to test ,for example, this use case in your code to make 88
sure that this is not working this is definitely not working 89
because this is related to the typing system that you are not 90
satisfying okay this a string this is not a function you 91
should not write that and that is why typescript is so 92
helpful it's going to tell you that you have something wrong 93
before the code is running. Okay ? Alright so that was a really 94
brief overview of Typescript and obviously for now as you 95
can see we haven't really written anything that is 96
specific to type script it's just JavaScript code so you 97
will see that we will have to write and learn the the 98
typescript syntax to really be able to produce this kind of 99
error and to make the code resilient and less prone to 100
errors. Alright, so see you in the next video to start 101
learning really how to use Typescript.