JavaScript with TypeScript 2.1

Microsoft's TypeScript (also regarded as industrial strength JavaScript)  is getting upgraded with new features:

Improved Inference
Async Functions


TypeScript 2.0 was released as recent as September 2016. TypeScript 2.1 is in RC (release candidate)

The upgrade makes modelling easier and migrating JavaScript to TypeScript easier. Aysnc/await () introduced in ECMAScript 2016  is featured in the new release and makes asynchronous programming easier. It shares same keywords in C#, Dart and Python.

Here is sample code from the msdn blog links above:
=====
async function main() {
 await ping();
}
async function ping() {
 for (var i = 0; i < 10; i++) {
  await delay(300);
  console.log(“ping”);
 }
}
function delay(ms: number) {
 return new Promise(resolve => setTimeout(resolve, ms));
}
main();
====
Read the rest of the story here if you are into programming with JavaScript.


Post a Comment

Popular posts from this blog

Develop a Side Menu App using Intel XDK - Part 1

UWP: XAML's ListView Control and its SelectionChanged event - Part 1

Setting up Kid's Corner on Windows 10 Phone