Typescript- Why we must use it in our JS projects ?
Type System

Typescript- Why we must use it in our JS projects ?

Hi folks ,

Today I have decided to discuss about TypeScript with you all , When I started to write my applications with Typescript , the first question that came to my head was , Why we have to use Typescript when we can write the same code with Javascript alone? , So I began to start studying about the importance of typescript and what benefits we are getting out of it

let's answer the basic question , What is TypeScript ?

Typescript is generally a type system , it is not a separate language like javascript ,it's a Superset of Javascript which means any javascript file is a typescript file .

If any Javascript file is a typescript file then why we are using Typescript specifically in our projects ?

Typescript is an extension of Javascript from this we can get an idea that typescript is going to give additional features to our Javascript code to meet our important needs

When Javascript was developed it was just meant to do some interactive actions on our browsers , later on it has become a language which we can use in any platform , Therefore it has given a privilege of building large applications when our application grows , managing it becomes a tedious task

Typescript is a language for application scale Javascript development , this helps us to write huge applications with Javascript and we can maintain it easily

As we all know Javascript is a loosely typed language it allows us to do many nonsensical things which may end with bugs to tackle these kind of bugs we must use typescript

Typescript helps us to write better code at zero cost , whenever a Typescript is compiled it just returns plain Javascript So, we are not going to lose because of Typescript , rather we are going to gain some significant benefits

As a React Developer we are creating alot of Reusable components when we re-use them we might forget or miss to pass a particular prop to that component which can be highlighted in our IDE when we use Typescript this can be found out even while we write our code and that prevents unwanted Runtime errors

let's see a small example , in which we want to add a number twice

const addNumbers = (val)=>{
return val + val 
}
 addNumers("hello")

The above code will work fine without throwing any error in normal Javascript but 
we won't be getting the expected output 
        




If we write the same code  with Typescript 
const addNumbers = (val)=>{
return val + val 
}
 addNumers("hello")
this will throw a compiler error when we try to excute this code , this is how 
typescript helps us to write better Javascript code        

In my coming articles will write about , how to use Typescript efficiently with React and Node JS and the idea of this article is to give brief introduction to Typescript , Hope you did like it !


Thanks for your time,

VMKrishna

要查看或添加评论,请登录

Vijayamuralikrishna J的更多文章

  • Closure on Hardware

    Closure on Hardware

    Hello Human, Today, I thought about discussing the concept of closure. Let's start with our usual question: What is a…

  • What is Proxy in Javascript ?

    What is Proxy in Javascript ?

    Hi Everyone , Today let's discuss about Proxy in JavaScript and how we can use them in our code. The very first basic…

  • React-State Management using URL

    React-State Management using URL

    Hi Reader , Today let's look at on how to store the state of our pages in the URL and those can be used to increase the…

  • Infinite Scroll Using Monad

    Infinite Scroll Using Monad

    Hi folks , Today I thought about discussing with you all about a code which was written with a lot of side effects and…

  • Type "any"- useful or useless?

    Type "any"- useful or useless?

    Hi folks , It's been sometime , did not write much lately and today I thought to write about type "any" and it's going…

  • Interface in Typescript

    Interface in Typescript

    Hi Folks , Today let's a take a look at Interface in typescript , from the word interface we can understand that we are…

    1 条评论
  • Types in Typescript

    Types in Typescript

    Hi all , As I said in my last article , will write about Typescript in my coming articles ,This is article belongs to…

  • Recursion - Basic Explanation

    Recursion - Basic Explanation

    Hi folks , Today I thought to write about Recursion, a powerful functional programming concept First, let's see the…

  • Play With Pics - Just a CANVAS

    Play With Pics - Just a CANVAS

    Hi Folks , Today I thought of sharing a simple application with you all , I just made this application to exhibit that,…

  • Scope Of React-Testing

    Scope Of React-Testing

    Hi folks, If you are a React developer then probably you will be writing test cases for your apps using jest and…

社区洞察

其他会员也浏览了