Table of contents
TypeScript makes our JavaScript codes more concise and beautiful.
It also makes our codes more understandable and easier to debug.
Typescript is open source and free :)
Typescript provides us with all the features of ES6
TypeScript helps prevent certain types of errors in our code, such as type-related issues, but it does not guarantee that our output code will be free of all grammatical bugs.
Typescript saves our time
JavaScript is a part of TypeScript!
It means that we still need to learn JavaScript. So, what is TypeScript? With TypeScript, we are essentially coding according to a modern coding standard. Take a look at the following code examples:
[] + []; // JavaScript: "", TypeScript will error
{} + []; // JS : 0, TS Error
[] + {}; // JS : "[object Object]", TS Error
{} + {}; // JS : NaN or [object Object][object Object], TS Error
"hello" - 1; // JS : NaN, TS Error
function add(a, b) {
return
a + b; // JS : undefined, TS Error 'unreachable code detected'
}
The above code snippets provide a small comparison of the behavior of JavaScript and TypeScript compilers. In all these examples, the JavaScript compiler does not give us any errors. However, for instance, there is no reason for our code's output to be a string on the first line! You can try it right now in your browser's console:
typeof ([] + []) // string
That's right! JavaScript's loose typing can lead to unexpected behavior and make debugging challenging. TypeScript, on the other hand, doesn't allow such loose behavior. If the TypeScript compiler encounters such issues, it will exit the compilation process, and we won't have any output until we fix our code correctly :). We are debugging right at that moment.
That's excellent! The introduction you've provided for starting with TypeScript is very good. We look forward to more information you'll be sharing. If you have questions or need further guidance, we're always here to assist you. Best of luck with learning and using TypeScript! ๐๐๐
resources:
https://www.typescriptlang.org/index.html
https://dev.to/singhdigamber/what-is-typescript-jig
https://basarat.gitbooks.io/typescript/docs/javascript/recap.html
https://dzone.com/articles/what-is-typescript-and-why-use-it