Typescript. What you should know about it


Typescript was made by Microsoft as they turned to javascript for web programming. They made it in such a way that it is OOP but compiles to JS during runtime. This development I may say was due to the fact that JS is dynamically typed which brings confusion and introduces errors in some cases.

TypeScript is just like a Superset of JavaScript. Code written in JavaScript can run in TypeScript. Just see it as JavaScript that is statically typed and follow the OOP concepts. It has object based classes.
I believe you must have heard about ECMAScript 6. It’s a JavaScript specification that is not yet supported by some browsers. This means that developers need transpilers(a program that helps to compile from on version of a programming language to another). A very Popular example of a transpiler is Babel. The use of these transpilers is a kind of a great pain to developers. This type of problem and some others are what TypeScript has solved. Developing in it automatically makes your code multi-browser and multiplatform based.

TypeScript was released on 1 October 2012. Not so many people know about it. I just wondered if it is the superset of JavaScript, how come JavaScript is more popular than it? The is reason is that its file needs to compile back to a standard JavaScript file because the browser can’t read a TypeScript file. Also, it is designed for larger applications can easily be integrated into JavaScript projects.

typescript code TypeScript Types

As it has been said earlier, it has types, unlike plain JavaScript. Here the types:

  • String
  • ¬†Array
  • Boolean
  • Numbers

Other types include:

  • Any: it can be anything
  • Void: no type returned
  • Null: no type at all
  • Tuple: an array with a fixed number of elements
  • Enum: Enumerated values
  • Generics: For creation of reusable code

Other interesting things about it is that:
It has a compiler called tsc that .ts file to .js (note that TypeScript file should have the extension of .ts)

So also, it is installed as an NPM package (Node.js) and it Supports the ES6 syntax.

Read More

You may also wish to read How to and why you should learn web development and designing

Kingsley Author


Leave a Reply

Your email address will not be published. Required fields are marked *