Hi friends, so I am from the C++ and the Java world, but I have always been interested in web development so I finally took the plunge and went into the JS world.
JS is wild. I was amazed, it’s like you have no rules. You don’t even need to write ‘int x’ if you want to use x as an integer, just do ‘let x’ and x is yours. I was enjoying building my project using MERN but as an open-source lovr, I wanted to contribute to projects. While diving into those projects, I realised that big projects that interest me use Typescript and something called monorepo (nothing but one single repo for all the things your project needs).
Now TypeScript, sweet TypeScript, is actually a superset of JS, whatever you write in JS you can write in TS(but don’t). Coming from a C++ background I felt validated, because in TS you have to define the types, for example you can do this in JS,
var x = 42;
x = “noob”;
and no one will say a word.
But in TS, if you do this, it will start crying because you defined x as a number.
var x: number = 42
x = “noob” /* invalid */
which is not a bad thing tbh.
🚀 How does the ts code is compiled?
The typescript compiler or the tsc does not compiles the code, it does two things:
- type checks the code
- converts ts code to js
And then the js code is compiled.
Pretty cool, right? 🚀 You can actually see that js file being created beside your ts file.
Anyways getting to the official definition,
“TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.”
Also fun fact, it was developed by Anders Hejlsberg, from Microsoft.
I will share more technical details later in this series where I deep dive and code with TypeScript.