TypeScript is a superset of JavaScript that enhances code quality and developer productivity by introducing static typing and additional features, though it requires a compilation step to JavaScript for execution.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
hello and welcome to another complete
course by proad me this course is about
typescript a super set of JavaScript
that means typescript is a programming
language which is built up on JavaScript
unlike JavaScript typescript has many
features which allow us to write less
error prone and cleaner code with some
exciting new features which is not
available in JavaScript yet so in this
course you will learn all about
typescript from scratch you don't need
to know anything about typescript to get
started but if you have a basic
JavaScript knowledge that is more than
enough to get started with this course
in this course you will learn all the
basics of typescript how it works why we
use it and the different advantages it
provides over using
JavaScript and slowly we will dive into
more and more advanced concepts of
typescript with this in this lecture
let's have a brief introduction of what
is typescript and what advantages does
it provides over JavaScript
in simple terms we can say that
typescript is a super set of JavaScript
typescript has all the features which
JavaScript provides plus it has some
extra features like interface access
modifiers Etc which is currently not
available in the latest version of
JavaScript and typescript makes writing
JavaScript easier and more powerful with
additional features which it
provides however we have one huge
disadvantage with
typescript typescript code cannot be
executed directly by the JavaScript
runtime like the browser or the nodejs
environment browsers or nodejs cannot
execute typescript code then why should
we use typescript and more importantly
how do we execute
it we have already answered the first
question before why should we use
typescript typescript has additional
features which does not exist in
JavaScript and hence it makes writing
JavaScript code much easier and faster
and also less error prone with
typescript now to answer how can we
execute typescript code typescript is
not just a programming language it is
also a tool it is a very powerful
compiler which can run and compile
typescript code into JavaScript so when
you run typescript code it gives you
JavaScript code in return and JavaScript
code can be executed by JavaScript
runtime like browser and nodejs so using
typescript we write typescript code
where we can utilize all the new
features of typescript and at the end we
get JavaScript code from that typescript
code which can be executed by the
browser or other JavaScript runtime we
do not write JavaScript code directly
when working with typescript instead we
write our code in typescript and when we
compile that typescript code it gets
converted into
JavaScript now that brings up one
another very important question how can
typescript use new features which is not
available in JavaScript and at the end
it gives us regular JavaScript code the
answer is the typescript compiler
compiles the new features of typescript
to JavaScript using some workarounds in
JavaScript for example we can write some
code in typescript using its new
features in a nice and simple way but
when it gets compiled to JavaScript
there that same nice and simple code
will have complex JavaScript logic and
syntax to achieve the same thing so
there is no magic here of course
typescript cannot output some JavaScript
code with features which JavaScript does
not support while converting typescript
code to JavaScript the new features will
be converted to JavaScript code using
existing features of JavaScript but in
typescript that code will be easy to
write with new features but same code in
JavaScript will be a little bit complex
and will use existing features of
JavaScript another very important
feature of typescript which does not
exist in JavaScript is typescript is
strongly typed it allows you to specify
a type for a variable explicitly on the
other hand JavaScript is dynamically
typed so here in the left hand side we
have JavaScript code and in the right
hand side we have typescript code so
when we create a variable in JavaScript
using let or const keyword there we
simply specify the variable name we
don't specify the type of data which
that variable is going to store for
example here I'm creating a variable num
to that we assigning this value 10 so
since JavaScript is dynamically typed
the data type of this num will be
calculated based on the value which we
are storing in it in this case the data
type of this num variable will be number
in the same way in this esta variable we
are storing a string value so its data
type will be dynamically calculated and
since we are storing a string value to
it its data type will be set to string
now the problem here is that
let's say I'm creating a variable using
let keyword and initially I'm assigning
100 to it so here the data type of this
Val variable will be number and in the
letter point of time to that same Val
variable now I'm assigning a string
value so here the data type of this Val
variable will change to string earlier
it was number now since we are storing a
string value in it its data type has
changed to string and that's why we say
that JavaScript is dynamic Ally typed
the data type of a variable in
JavaScript is determined by the value
which we are storing in it and the
variables data type can change based on
what type of value we are storing in it
but that is not the case in typescript
typescript is strongly typed that means
here when we are creating this num
variable and we assigning 10 to it the
data type of this num variable will be
set to number in the same way when we
are creating this SDR variable and when
we we assigning a string value to it its
data type will be set to string so
letter we cannot go ahead and assign a
number to it for example here we are
creating this Val variable again in
typescript and to this I'm assigning a
numeric value so the data type of this
well variable will be set to number now
in the letter point of time in the same
well variable if I try to assign a
string value we will get an error
because its data type has already been
set to number so we cannot assign a
string value to it also if we want in
typescript we can explicitly specify the
data type of a variable for example here
as you can see for this num I'm
explicitly specifying that this num
variable is only going to store a
numeric value this SDR variable it is
only going to store a string value if we
try to assign any other type of value to
this variable it is going to throw us an
error now what is the advantage of
typescript being strongly typed Ty well
it gives us an opportunity of
identifying any errors in our code
earlier before we run and compile the
code and it also allows us to identify
and fix any bugs at the earlier stage of
our development let's understand this
with an
example so again in the left hand side I
have JavaScript code and in the right
hand side I have typescript code and
here what we are doing is we are
creating a function called add which
should add two numbers and return return
us the result now here when we are
specifying this parameter num one and
num two we are not specifying that this
num one and num two should only receive
a numeric value right because that is
not possible in JavaScript you cannot
specify a data type for a variable or a
parameter so when we are going to call
this add function like we are doing here
at that time for this num one and num
two we can pass any type of value we can
pass a string value we can pass a
numeric value we can pass a Boolean
value we can pass n undefined anything
and that will be assigned to this num
one and num two
parameter so in this case if a user
tries to add two numbers three and five
but he has passed that number as a
string value like we are doing here in
that case the expected output will be 8
but here the result will be 35 why
because since we are trying to use this
plus operator on two string values those
two strings will get
concatenated it will not add the them it
will concatenate them because they are
string values so in that case we are
going to get an unexpected result but if
the same thing we try to do in
typescript there we can explicitly
specify what type of data we are
expecting for this num one and num two
parameter in this case we explicitly
specifying that for Num one and num two
we only want to get the numeric value so
while calling this add function if we
try to pass a string value or a Boolean
value for this num one and num two we
will immediately get an error and we can
Rectify it so here the typescript will
only allow us to pass a numeric value
for this num one and num two and in this
way we can avoid that bug we can avoid
that unexpected result so this is the
advantage of typescript being strongly
typed and we are going to talk about
this feature in great detail in our
coming lectures in this course so let's
quickly recap the advantages of using
typescript which we have talked about so
far first of all we can explicitly
specify the data type of a variable
which allows us to catch any error and
avoid bugs while writing the code
another Advantage which we talked about
is typescript also provides extra
features which is not available in the
current version of JavaScript and this
makes writing certain Logics in
typescript easy and simple without these
features writing the same code writing
the same logic logic might be a little
bit complex but using the new features
it makes writing the complex code easier
and simple and also less error
prone apart from new features typescript
also has meta features like decorators
which we will talk about in great detail
in this
course and typescript is also highly
configurable in this course you will
also learn in detail about typescript
compiler and how to configure it so you
can fine-tune the typescript compiler to
your requirement to make sure that it
behaves in the way you want it to behave
the only disadvantage with typescript is
that it has one extra step of compiling
the typescript code to JavaScript before
it gets executed by the JavaScript
runtime so this is the only disadvantage
of using
typescript all right so this was a very
high level overview of what is
typescript and why you might want to
learn and use it in your project in the
next lecture let's install and let's
start using typescript this is all from
this lecture thank you for listening and
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.