TypeScript is a programming language first developed by Microsoft in 2012. Its main ambition is to improve the productivity of developing complex applications. It is an open-source language developed as a superset of JavaScript. What this means in simple terms is that any code valid in JavaScript is also valuable for TypeScript. However, the language introduces optional features like typing or object-oriented programming. To benefit from these features, no library is required. Instead, just use the TypeScript compilation tool to transpile it (compiling the source code of one language into another language) into JavaScript. Thus, the executed code will be a Javascript equivalent of the compiled TypeScript code.
TypeScript has been increasing in its popularity for the last couple of years. Angular, one of the largest frontend frameworks is using TypeScript. About 60% of JS programmers already use TypeScript, and
22% wish to try.
TypeScript has a variety of basic types, like Boolean, Number, String, Array, Tuple, etc. Some of these don't exist in JS; you can learn more about them in the documentation of TypeScript. In addition to those, here are some other types we want to feature to showcase the expressivity of TS:
While any as a type can cover, well, anything that you wish, unknown is its type-safe counterpart. Whenever you want to escape the type system, and enables you to assign any JavaScript variable to it. It is frequently used to model incoming variables (from third-party APIs, for example) that have not yet been checked and whose type is unknown. The unknown is a lot like any, but it won't let you perform any operations on the variable before it is explicitly type-checked.
Void is used when there is no value returned, for example, as the return type of functions that return nothing.
Never is the return type for something that should never occur, like a function that will throw an exception.
These enable you to create custom types to better fit your logic. Intersection types enable you to put together several basic types in one type. For example, you could create a custom type Person that has a name: string and a phone_number: number. It is equivalent to saying: I want my type to be this and that.
Union types enable your type to take one of the multiple basic types. For example, you could have a query that returns either result: a string or undefined. It is equivalent to saying: I want my type to be this or that.
There are three fundamental components of TypeScript that make it as awesome as it is. Not only do we get the aforementioned type-checking that comes with the TypeScript language, but we get the TypeScript compiler and language service as well. There's another key piece to TypeScript's relevance that often goes overlooked: it's super well-supported by text editors. TypeScript's relevance is only as good as it is accessible and something that can be picked up by just about any front-ender.
TypeScript was initially supported only in Microsoft's Visual Studio code editor because TypeScript is maintained by Microsoft and all. But as TypeScript grew legs, more code editors and IDEs began started supporting it either natively or with plugins.
TypeScript is essentially a JS linter. Or, JS with documentation that the compiler can understand. Therefore, in contrast to other languages like CoffeeScript (which adds syntactic sugar) or PureScript (which does not look like JavaScript at all), you do not need to learn a lot to start writing TypeScript code.
The average senior typescript developer salary in the USA is US$130,000 per year or US$66.67 per hour. Entry-level positions start at US$120,000 per year while most experienced workers make up to US$165,000 per year.
Join our WhatsApp Channel to get the latest news, exclusives and videos on WhatsApp
_____________
Disclaimer: Analytics Insight does not provide financial advice or guidance. Also note that the cryptocurrencies mentioned/listed on the website could potentially be scams, i.e. designed to induce you to invest financial resources that may be lost forever and not be recoverable once investments are made. You are responsible for conducting your own research (DYOR) before making any investments. Read more here.