Welcome Guest! (App Version 5.16)

websitnero logo name


TypeScript in Angular

TypeScript is a super-set of JavaScript which means that it has all the functionalities and tools provided by JavaScript but also some more tools and items that can be used by a programmer most of which are as per mentioned in ES6. As we know that browsers do not support or understand ES6. They also do not understand any pre-compiler based on ES6, which simply means that they do not understand TypeScript also. Then whey to use TypeScript?

Why to use TypeScript?

There are many new features in ES6 that might prove benefitial like arrow-functions or compulsion of adding types to variables. There are new items like Let and Const. These in time will be able to reduce the coding effort required by a far greater amount.

Do Browsers understand ES6 or TypeScript?

As already mentioned Browsers understand only Vanilla JavaScript or ES5 version of JavaScript. None of the browsers supports ES6 or pre-compilers based on it. So, the main way is to write the code in TypeScript, CoffeeScript, etc. and then compile them back to Vanilla JavaScript. This way after the compilation when we get plain JavaScript, this file can be attached to 'index.html' and then browser will be able to understand it.

Note: "TypeScript is based on ES6 version of JavaSript and all the code that you write finally gets compiled to ES5 version which is easily understood and rendered by Web Browsers."

Can we write our code in JavaScript rather than using TypeScript in Angular?

All the code that you write in TypeScript will finally get converted to JavaScript only. This means YES!, you can write all the code in simple JavaScript while using Angular, but it would take much more time and effort. This defeats the basic purpose of using JavaScript Framework, which is to reduce the time and effort for developing a project.

Note: "You may write your code in plain JavaScript but then the facilities and tools provided by TypeScript would be lost and more time and effots would be required to get the same amount of work done."

WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.