What is TypeScript?

TypeScript, Programming Language, Web Development,

When we are writing TypeScript code, we are just writing JavaScript.

  // TypeScript = JavaScript + A Type System 
  const name: string = "NRG Nomad";
  const isBlog: boolean = true;

TypeScript is very powerful compiler that you can run over your code to compile your typescript code to JavaScript.

Type System is helping us catch errors during the development. The Type System is only available during the development. Once we deploy our application or even run inside of our browser in a development environment, the entire type of system falls away. Before we are running code, we need to compile our typescript code, and we are going to get some JavaScript out of that.

TypeScript is going to be constantly analyzing our code and looking for bugs. If it finds any possible bug, it will pop an open error message inside your code editor.

FYI - The TypeScript compiler does not do any performance optimization.

TypeScript Compiler is using "TYPE ANNOTATIONS" to analyze our codebase. A developer is responsible for adding these "type annotations .". Imagine these "type annotations " as being like comments to describe your code's purpose or the information flowing through our program.

( Learn JavaScrtipt First to understand TypeScript )

TypeScript Code -> TypeScript Compiler -> JavaScript :):):)

A developer using TypeScript is impressive because it gives you extra error checking where errors you would otherwise get as runtime can be caught and fixed early during development.

Whit types, we need to be way more explicit about how things work, and we can avoid many unexpected errors

We can use certain next-generation JavaScript features, which you can write and use in our typescript files, and then they will get compiled down to JavaScript code to workarounds that even work in older browsers.

VS Code gets support in non TypeScript Projects. VS Code gives you better help in plain JavaScript files because it can use some types of features under the hood without explicitly using typescript.

Start with TypeScript:

  • install nodejs - https://nodejs.org/en/
 const command: string = "sudo npm install -g typescript"